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

N = 1
observations = []
def solve(s):
    return {
        'queue': s['serial'] and s['depth']>0 and s['event'] is not None,
        'enter': s['event'] is not None and not(s['serial'] and s['depth']>0) and s['depth']<s['limit'],
        'outer_event': s['outer'],
        'context': s['context'],
        'unwind': s['frames'][:-1] if s['complete'] else list(s['frames']),
        'drain': list(s['pending']) if s['complete'] and s['depth']<=1 else [],
        'parent_cancel': False,
        'overflow': s['event'] is not None and s['depth']>=s['limit'] and not(s['serial'] and s['depth']>0),
        'next_depth': max(0,s['depth']-int(s['complete'])),
        'queued_order': ([s['event']] if s['event'] is not None else [])+list(s['pending']),
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'depth': 0, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 3, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': 'outer', 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 2, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 0, 'limit': 4, 'serial': False, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': True, 'outer_event': 'outer', 'context': None, 'unwind': ['root'], 'drain': ['a', 'b'], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 1, 'limit': 4, 'serial': True, 'pending': [], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': ['root']}, {'queue': True, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 1, 'queued_order': ['inner']}), ({'depth': 1, 'limit': 1, 'serial': True, 'pending': [], 'event': None, 'outer': 'outer', 'context': None, 'cancel': False, 'complete': False, 'frames': ['root']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 1, 'queued_order': []}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': [], 'event': 'inner', 'outer': None, 'context': None, 'cancel': True, 'complete': False, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': []}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': [], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': []}), ({'depth': 3, 'limit': 4, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 2, 'queued_order': ['a', 'b']})], 2: [({'depth': 0, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': ['root']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 6, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 5, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 0, 'limit': 8, 'serial': False, 'pending': [], 'event': 'inner', 'outer': None, 'context': None, 'cancel': False, 'complete': True, 'frames': ['root']}, {'queue': False, 'enter': True, 'outer_event': None, 'context': None, 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': []}), ({'depth': 1, 'limit': 8, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': None, 'cancel': True, 'complete': True, 'frames': []}, {'queue': True, 'enter': False, 'outer_event': 'outer', 'context': None, 'unwind': [], 'drain': ['a', 'b'], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 6, 'limit': 1, 'serial': True, 'pending': [], 'event': 'inner', 'outer': None, 'context': None, 'cancel': False, 'complete': False, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 6, 'queued_order': ['inner']}), ({'depth': 1, 'limit': 0, 'serial': False, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 1, 'queued_order': ['a', 'b']}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': [], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': []}), ({'depth': 6, 'limit': 8, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 5, 'queued_order': ['a', 'b']})], 3: [({'depth': 0, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 9, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 8, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 0, 'limit': 1, 'serial': False, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': True, 'frames': ['root']}, {'queue': False, 'enter': True, 'outer_event': None, 'context': 'ctx', 'unwind': [], 'drain': ['a', 'b'], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 1, 'limit': 12, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': None, 'cancel': False, 'complete': False, 'frames': ['root']}, {'queue': True, 'enter': False, 'outer_event': 'outer', 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 1, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 9, 'limit': 1, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': 'ctx', 'cancel': False, 'complete': True, 'frames': ['root']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 8, 'queued_order': ['a', 'b']}), ({'depth': 9, 'limit': 12, 'serial': False, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 9, 'queued_order': ['a', 'b']}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': [], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': []}), ({'depth': 9, 'limit': 12, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 8, 'queued_order': ['a', 'b']})], 4: [({'depth': 0, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': ['root']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 12, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 11, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 0, 'limit': 16, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': True, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': [], 'drain': ['a', 'b'], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 1, 'limit': 16, 'serial': True, 'pending': [], 'event': 'inner', 'outer': 'outer', 'context': None, 'cancel': False, 'complete': False, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': 'outer', 'context': None, 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 1, 'queued_order': ['inner']}), ({'depth': 0, 'limit': 16, 'serial': False, 'pending': [], 'event': None, 'outer': 'outer', 'context': None, 'cancel': True, 'complete': False, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': None, 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': []}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': ['root']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': [], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': []}), ({'depth': 12, 'limit': 16, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 11, 'queued_order': ['a', 'b']})], 5: [({'depth': 0, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 15, 'limit': 20, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 14, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 0, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': 'outer', 'context': 'ctx', 'cancel': True, 'complete': True, 'frames': ['root']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': [], 'drain': ['a', 'b'], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 15, 'limit': 1, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': False, 'complete': True, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 14, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 0, 'limit': 20, 'serial': True, 'pending': [], 'event': None, 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': []}), ({'depth': 15, 'limit': 1, 'serial': False, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 15, 'queued_order': ['a', 'b']}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': [], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': []}), ({'depth': 15, 'limit': 20, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 14, 'queued_order': ['a', 'b']})]}
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 {
        'queue': s['serial'] and s['depth']>0 and s['event'] is not None,
        'enter': s['event'] is not None and not(s['serial'] and s['depth']>0) and s['depth']<s['limit'],
        'outer_event': s['outer'],
        'context': s['context'],
        'unwind': s['frames'][:-1] if s['complete'] else list(s['frames']),
        'drain': list(s['pending']) if s['complete'] and s['depth']<=1 else [],
        'parent_cancel': False,
        'overflow': s['event'] is not None and s['depth']>=s['limit'] and not(s['serial'] and s['depth']>0),
        'next_depth': max(0,s['depth']-int(s['complete'])),
        'queued_order': list(s['pending'])+([s['event']] if s['serial'] and s['event'] is not None else []),
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'depth': 0, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 3, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': 'outer', 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 2, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 0, 'limit': 4, 'serial': False, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': True, 'outer_event': 'outer', 'context': None, 'unwind': ['root'], 'drain': ['a', 'b'], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 1, 'limit': 4, 'serial': True, 'pending': [], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': ['root']}, {'queue': True, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 1, 'queued_order': ['inner']}), ({'depth': 1, 'limit': 1, 'serial': True, 'pending': [], 'event': None, 'outer': 'outer', 'context': None, 'cancel': False, 'complete': False, 'frames': ['root']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 1, 'queued_order': []}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': [], 'event': 'inner', 'outer': None, 'context': None, 'cancel': True, 'complete': False, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': []}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': [], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': []}), ({'depth': 3, 'limit': 4, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 2, 'queued_order': ['a', 'b']})], 2: [({'depth': 0, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': ['root']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 6, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 5, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 0, 'limit': 8, 'serial': False, 'pending': [], 'event': 'inner', 'outer': None, 'context': None, 'cancel': False, 'complete': True, 'frames': ['root']}, {'queue': False, 'enter': True, 'outer_event': None, 'context': None, 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': []}), ({'depth': 1, 'limit': 8, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': None, 'cancel': True, 'complete': True, 'frames': []}, {'queue': True, 'enter': False, 'outer_event': 'outer', 'context': None, 'unwind': [], 'drain': ['a', 'b'], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 6, 'limit': 1, 'serial': True, 'pending': [], 'event': 'inner', 'outer': None, 'context': None, 'cancel': False, 'complete': False, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 6, 'queued_order': ['inner']}), ({'depth': 1, 'limit': 0, 'serial': False, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 1, 'queued_order': ['a', 'b']}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': [], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': []}), ({'depth': 6, 'limit': 8, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 5, 'queued_order': ['a', 'b']})], 3: [({'depth': 0, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 9, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 8, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 0, 'limit': 1, 'serial': False, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': True, 'frames': ['root']}, {'queue': False, 'enter': True, 'outer_event': None, 'context': 'ctx', 'unwind': [], 'drain': ['a', 'b'], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 1, 'limit': 12, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': None, 'cancel': False, 'complete': False, 'frames': ['root']}, {'queue': True, 'enter': False, 'outer_event': 'outer', 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 1, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 9, 'limit': 1, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': 'ctx', 'cancel': False, 'complete': True, 'frames': ['root']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 8, 'queued_order': ['a', 'b']}), ({'depth': 9, 'limit': 12, 'serial': False, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 9, 'queued_order': ['a', 'b']}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': [], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': []}), ({'depth': 9, 'limit': 12, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 8, 'queued_order': ['a', 'b']})], 4: [({'depth': 0, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': ['root']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 12, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 11, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 0, 'limit': 16, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': True, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': [], 'drain': ['a', 'b'], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 1, 'limit': 16, 'serial': True, 'pending': [], 'event': 'inner', 'outer': 'outer', 'context': None, 'cancel': False, 'complete': False, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': 'outer', 'context': None, 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 1, 'queued_order': ['inner']}), ({'depth': 0, 'limit': 16, 'serial': False, 'pending': [], 'event': None, 'outer': 'outer', 'context': None, 'cancel': True, 'complete': False, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': None, 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': []}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': ['root']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': [], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': []}), ({'depth': 12, 'limit': 16, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 11, 'queued_order': ['a', 'b']})], 5: [({'depth': 0, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': ['root', 'child'], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 15, 'limit': 20, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 14, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 0, 'limit': 0, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': 'outer', 'context': 'ctx', 'cancel': True, 'complete': True, 'frames': ['root']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': [], 'drain': ['a', 'b'], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': ['a', 'b']}), ({'depth': 15, 'limit': 1, 'serial': True, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': False, 'complete': True, 'frames': ['root', 'child']}, {'queue': True, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 14, 'queued_order': ['a', 'b', 'inner']}), ({'depth': 0, 'limit': 20, 'serial': True, 'pending': [], 'event': None, 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 0, 'queued_order': []}), ({'depth': 15, 'limit': 1, 'serial': False, 'pending': ['a', 'b'], 'event': 'inner', 'outer': None, 'context': 'ctx', 'cancel': True, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': None, 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 15, 'queued_order': ['a', 'b']}), ({'depth': 0, 'limit': 0, 'serial': False, 'pending': [], 'event': 'inner', 'outer': 'outer', 'context': 'ctx', 'cancel': False, 'complete': False, 'frames': []}, {'queue': False, 'enter': False, 'outer_event': 'outer', 'context': 'ctx', 'unwind': [], 'drain': [], 'parent_cancel': False, 'overflow': True, 'next_depth': 0, 'queued_order': []}), ({'depth': 15, 'limit': 20, 'serial': True, 'pending': ['a', 'b'], 'event': None, 'outer': None, 'context': None, 'cancel': True, 'complete': True, 'frames': ['root', 'child']}, {'queue': False, 'enter': False, 'outer_event': None, 'context': None, 'unwind': ['root'], 'drain': [], 'parent_cancel': False, 'overflow': False, 'next_depth': 14, 'queued_order': ['a', 'b']})]}
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:
Deferred reentrant emissions are prepended in LIFO order; the returned lifecycle plan violates the stated transition contract.

Plan a nested observer emission with bounded depth. A nested event queues when serialization is enabled; otherwise it opens a child frame if below the limit. Preserve the outer event/context, unwind exactly one frame, and drain deferred events only after the outermost callback completes. A cancelled inner frame never cancels its parent. 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: queue = s['serial'] and s['depth']>0 and s['event'] is not None; enter = s['event'] is not None and not(s['serial'] and s['depth']>0) and s['depth']<s['limit']; outer_event = s['outer']; context = s['context']; unwind = s['frames'][:-1] if s['complete'] else list(s['frames']); drain = list(s['pending']) if s['complete'] and s['depth']<=1 else []; parent_cancel = False; overflow = s['event'] is not None and s['depth']>=s['limit'] and not(s['serial'] and s['depth']>0); next_depth = max(0,s['depth']-int(s['complete'])); queued_order = list(s['pending'])+([s['event']] if s['serial'] and s['depth']>0 and s['event'] is not None else [])

split: open-access


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

N = 1
observations = []
def solve(s):
    return {
        'capture': list(reversed(s['path'][:-1])),
        'bubble': list(reversed(s['path'][:-1])) if s['bubbles'] else [],
        'target': s['path'][-1] if s['path'] else None,
        'next_node': not s['stopped'] and not s['immediate'],
        'siblings': 0 if s['immediate'] else s['siblings'],
        'default_prevented': s['prevented'] or (s['prevent'] and s['cancelable'] and not s['passive']),
        'default_run': not s['prevented'] and not(s['prevent'] and s['cancelable'] and not s['passive']),
        'current_target': s['current'],
        'path_copy': list(s['path']),
        'prevent_ignored': s['prevent'] and (s['passive'] or not s['cancelable']),
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 3, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 3, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': False, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 3, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': True}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 0, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': False, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': False, 'prevent': False, 'prevented': True, 'siblings': 0, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': False}), ({'path': ['target'], 'bubbles': True, 'stopped': True, 'immediate': False, 'cancelable': False, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 0, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': False, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 0, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': True, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': True}), ({'path': [], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': False, 'passive': False, 'prevent': False, 'prevented': False, 'siblings': 0, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': True, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': True, 'siblings': 3, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True})], 2: [({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 6, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 6, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': True, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 6, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['target'], 'prevent_ignored': True}), ({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': False, 'prevented': True, 'siblings': 6, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': False}), ({'path': [], 'bubbles': False, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': False, 'prevented': False, 'siblings': 6, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': False, 'siblings': 6, 'default_prevented': False, 'default_run': True, 'current_target': 'target', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['target'], 'bubbles': True, 'stopped': True, 'immediate': False, 'cancelable': False, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 0, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['target'], 'prevent_ignored': True}), ({'path': [], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': True, 'prevent': False, 'prevented': True, 'siblings': 6, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': [], 'prevent_ignored': False}), ({'path': [], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': False, 'passive': False, 'prevent': False, 'prevented': False, 'siblings': 0, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': True, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': True, 'siblings': 6, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True})], 3: [({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 9, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 9, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 9, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': True, 'stopped': False, 'immediate': True, 'cancelable': True, 'passive': False, 'prevent': True, 'prevented': False, 'siblings': 9, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['target'], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 0, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': False, 'prevent': False, 'prevented': True, 'siblings': 9, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': False, 'prevent': True, 'prevented': False, 'siblings': 9, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': False}), ({'path': [], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': False, 'passive': False, 'prevent': False, 'prevented': False, 'siblings': 0, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': True, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': True, 'siblings': 9, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True})], 4: [({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 12, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 12, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 12, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': False, 'passive': True, 'prevent': False, 'prevented': True, 'siblings': 12, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': False, 'prevent': False, 'prevented': True, 'siblings': 0, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': False}), ({'path': [], 'bubbles': True, 'stopped': True, 'immediate': False, 'cancelable': False, 'passive': True, 'prevent': False, 'prevented': False, 'siblings': 12, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': False, 'siblings': 12, 'default_prevented': False, 'default_run': True, 'current_target': 'target', 'path_copy': [], 'prevent_ignored': False}), ({'path': [], 'bubbles': False, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': False, 'prevent': True, 'prevented': False, 'siblings': 12, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': [], 'prevent_ignored': False}), ({'path': [], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': False, 'passive': False, 'prevent': False, 'prevented': False, 'siblings': 0, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': True, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': True, 'siblings': 12, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True})], 5: [({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 15, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 15, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': True, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 15, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': True}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': False, 'cancelable': False, 'passive': True, 'prevent': False, 'prevented': False, 'siblings': 15, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 15, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': False}), ({'path': [], 'bubbles': True, 'stopped': False, 'immediate': True, 'cancelable': True, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 0, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': True, 'passive': False, 'prevent': False, 'prevented': True, 'siblings': 15, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': True, 'siblings': 15, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': False}), ({'path': ['target'], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': False, 'prevented': True, 'siblings': 0, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': True, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': False}), ({'path': [], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': False, 'passive': False, 'prevent': False, 'prevented': False, 'siblings': 0, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': True, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': True, 'siblings': 15, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True})]}
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 {
        'capture': list(s['path']),
        'bubble': list(reversed(s['path'][:-1])) if s['bubbles'] else [],
        'target': s['path'][-1] if s['path'] else None,
        'next_node': not s['stopped'] and not s['immediate'],
        'siblings': 0 if s['immediate'] else s['siblings'],
        'default_prevented': s['prevented'] or (s['prevent'] and s['cancelable'] and not s['passive']),
        'default_run': not s['prevented'] and not(s['prevent'] and s['cancelable'] and not s['passive']),
        'current_target': s['current'],
        'path_copy': list(s['path']),
        'prevent_ignored': s['prevent'] and (s['passive'] or not s['cancelable']),
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 3, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 3, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': False, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 3, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': True}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 0, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': False, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': False, 'prevent': False, 'prevented': True, 'siblings': 0, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': False}), ({'path': ['target'], 'bubbles': True, 'stopped': True, 'immediate': False, 'cancelable': False, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 0, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': False, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 0, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': True, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': True}), ({'path': [], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': False, 'passive': False, 'prevent': False, 'prevented': False, 'siblings': 0, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': True, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': True, 'siblings': 3, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True})], 2: [({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 6, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 6, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': True, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 6, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['target'], 'prevent_ignored': True}), ({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': False, 'prevented': True, 'siblings': 6, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': False}), ({'path': [], 'bubbles': False, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': False, 'prevented': False, 'siblings': 6, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': False, 'siblings': 6, 'default_prevented': False, 'default_run': True, 'current_target': 'target', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['target'], 'bubbles': True, 'stopped': True, 'immediate': False, 'cancelable': False, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 0, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['target'], 'prevent_ignored': True}), ({'path': [], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': True, 'prevent': False, 'prevented': True, 'siblings': 6, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': [], 'prevent_ignored': False}), ({'path': [], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': False, 'passive': False, 'prevent': False, 'prevented': False, 'siblings': 0, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': True, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': True, 'siblings': 6, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True})], 3: [({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 9, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 9, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 9, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': True, 'stopped': False, 'immediate': True, 'cancelable': True, 'passive': False, 'prevent': True, 'prevented': False, 'siblings': 9, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['target'], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 0, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': False, 'prevent': False, 'prevented': True, 'siblings': 9, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': False, 'prevent': True, 'prevented': False, 'siblings': 9, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': False}), ({'path': [], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': False, 'passive': False, 'prevent': False, 'prevented': False, 'siblings': 0, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': True, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': True, 'siblings': 9, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True})], 4: [({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 12, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 12, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 12, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': False, 'passive': True, 'prevent': False, 'prevented': True, 'siblings': 12, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': False, 'prevent': False, 'prevented': True, 'siblings': 0, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': False}), ({'path': [], 'bubbles': True, 'stopped': True, 'immediate': False, 'cancelable': False, 'passive': True, 'prevent': False, 'prevented': False, 'siblings': 12, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': False, 'siblings': 12, 'default_prevented': False, 'default_run': True, 'current_target': 'target', 'path_copy': [], 'prevent_ignored': False}), ({'path': [], 'bubbles': False, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': False, 'prevent': True, 'prevented': False, 'siblings': 12, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': [], 'prevent_ignored': False}), ({'path': [], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': False, 'passive': False, 'prevent': False, 'prevented': False, 'siblings': 0, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': True, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': True, 'siblings': 12, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True})], 5: [({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': True, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': False, 'siblings': 15, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 15, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True}), ({'path': ['target'], 'bubbles': True, 'stopped': False, 'immediate': True, 'cancelable': False, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 15, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': True}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': False, 'cancelable': False, 'passive': True, 'prevent': False, 'prevented': False, 'siblings': 15, 'current': 'root'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 15, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': False}), ({'path': [], 'bubbles': True, 'stopped': False, 'immediate': True, 'cancelable': True, 'passive': False, 'prevent': True, 'prevented': True, 'siblings': 0, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': True, 'passive': False, 'prevent': False, 'prevented': True, 'siblings': 15, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': [], 'target': 'target', 'next_node': True, 'siblings': 15, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': False}), ({'path': ['target'], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': True, 'passive': True, 'prevent': False, 'prevented': True, 'siblings': 0, 'current': 'target'}, {'capture': [], 'bubble': [], 'target': 'target', 'next_node': True, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['target'], 'prevent_ignored': False}), ({'path': [], 'bubbles': False, 'stopped': False, 'immediate': False, 'cancelable': False, 'passive': False, 'prevent': False, 'prevented': False, 'siblings': 0, 'current': 'root'}, {'capture': [], 'bubble': [], 'target': None, 'next_node': True, 'siblings': 0, 'default_prevented': False, 'default_run': True, 'current_target': 'root', 'path_copy': [], 'prevent_ignored': False}), ({'path': ['root', 'middle', 'target'], 'bubbles': True, 'stopped': True, 'immediate': True, 'cancelable': True, 'passive': True, 'prevent': True, 'prevented': True, 'siblings': 15, 'current': 'target'}, {'capture': ['root', 'middle'], 'bubble': ['middle', 'root'], 'target': 'target', 'next_node': False, 'siblings': 0, 'default_prevented': True, 'default_run': False, 'current_target': 'target', 'path_copy': ['root', 'middle', 'target'], 'prevent_ignored': True})]}
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:
Capture propagation begins at the target instead of the root; the returned lifecycle plan violates the stated transition contract.

A stipulated non-UI event path is root-to-target. Capture visits ancestors in that order; bubble visits ancestors in reverse only for bubbling events. Target is visited once. stopPropagation prevents later nodes but not sibling callbacks on the current node; stopImmediate prevents both. Only cancelable, nonpassive listeners may prevent the default action. A prior prevented marker is monotonic. 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: capture = s['path'][:-1]; bubble = list(reversed(s['path'][:-1])) if s['bubbles'] else []; target = s['path'][-1] if s['path'] else None; next_node = not s['stopped'] and not s['immediate']; siblings = 0 if s['immediate'] else s['siblings']; default_prevented = s['prevented'] or (s['prevent'] and s['cancelable'] and not s['passive']); default_run = not s['prevented'] and not(s['prevent'] and s['cancelable'] and not s['passive']); current_target = s['current']; path_copy = list(s['path']); prevent_ignored = s['prevent'] and (s['passive'] or not s['cancelable'])

split: open-access