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

N = 1
observations = []
def solve(s):
    return {
        'continue': s['error']!='fatal' and not(s['error'] is not None and s['failfast']),
        'cleanup': s['acquired'] and not s['cleanup_done'],
        'report': s['error'] is not None and not s['reported'] and (not s['handler'] or s['error']=='fatal'),
        'collected': list(s['errors'])+([s['error']] if s['error'] is not None else []),
        'handler_call': s['handler'] and s['error']=='recoverable',
        'value': s['result'] or None,
        'remaining': s['siblings'] if s['error']=='fatal' or (s['error'] is not None and s['failfast']) else 0,
        'active': s['active'] and s['error']!='fatal',
        'handled': s['handler'] and s['error']=='recoverable' and not s['failfast'],
        'fatal': s['error']=='fatal',
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 3, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 3, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 3, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 3, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': True, 'cleanup': False, 'report': True, 'collected': ['earlier', 'recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'recoverable', 'failfast': True, 'handler': False, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': None, 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['earlier', 'recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': 'ok', 'errors': [], 'active': False}, {'continue': True, 'cleanup': True, 'report': False, 'collected': [], 'handler_call': False, 'value': 'ok', 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 3, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 3, 'active': False, 'handled': False, 'fatal': True})], 2: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 6, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 6, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 6, 'result': None, 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 6, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 6, 'result': 0, 'errors': ['earlier'], 'active': False}, {'continue': True, 'cleanup': True, 'report': True, 'collected': ['earlier', 'recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': None, 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': 0, 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': True, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 0, 'result': 0, 'errors': [], 'active': False}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 6, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 6, 'active': False, 'handled': False, 'fatal': True})], 3: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 9, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 9, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 9, 'result': 'ok', 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': 'ok', 'errors': [], 'active': False}, {'continue': True, 'cleanup': True, 'report': False, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 9, 'result': 'ok', 'errors': [], 'active': False}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': True, 'siblings': 9, 'result': None, 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 0, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': True}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 9, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True})], 4: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 12, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 12, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 12, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 12, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': 'ok', 'errors': [], 'active': True}, {'continue': True, 'cleanup': False, 'report': False, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': False, 'siblings': 12, 'result': 'ok', 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 12, 'active': False, 'handled': False, 'fatal': True}), ({'error': None, 'failfast': True, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 12, 'result': 'ok', 'errors': [], 'active': True}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': 'ok', 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': True, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 12, 'result': 0, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': 0, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 12, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 12, 'active': False, 'handled': False, 'fatal': True})], 5: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 15, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 15, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 15, 'result': None, 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 15, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': True}, {'continue': True, 'cleanup': True, 'report': False, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': True, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': 'ok', 'errors': ['earlier'], 'active': False}, {'continue': True, 'cleanup': True, 'report': False, 'collected': ['earlier'], 'handler_call': False, 'value': 'ok', 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'recoverable', 'failfast': False, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': True, 'siblings': 15, 'result': 0, 'errors': ['earlier'], 'active': True}, {'continue': True, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 0, 'active': True, 'handled': True, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': True, 'siblings': 15, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 15, 'active': False, 'handled': False, 'fatal': True}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 15, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 15, 'active': False, 'handled': False, 'fatal': 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)

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

N = 1
observations = []
def solve(s):
    return {
        'continue': s['error']!='fatal' and not(s['error'] is not None and s['failfast']),
        'cleanup': s['acquired'] and not s['cleanup_done'],
        'report': s['error'] is not None and not s['reported'] and (not s['handler'] or s['error']=='fatal'),
        'collected': list(s['errors'])+([s['error']] if s['error'] is not None else []),
        'handler_call': s['handler'] and s['error']=='recoverable',
        'value': s['result'],
        'remaining': s['siblings'] if s['error']=='fatal' or (s['error'] is not None and s['failfast']) else 0,
        'active': s['active'] and s['error']!='fatal',
        'handled': s['handler'] and s['error']=='recoverable' and not s['failfast'],
        'fatal': s['error']=='fatal',
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 3, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 3, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 3, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 3, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': True, 'cleanup': False, 'report': True, 'collected': ['earlier', 'recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'recoverable', 'failfast': True, 'handler': False, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': None, 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['earlier', 'recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': 'ok', 'errors': [], 'active': False}, {'continue': True, 'cleanup': True, 'report': False, 'collected': [], 'handler_call': False, 'value': 'ok', 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 3, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 3, 'active': False, 'handled': False, 'fatal': True})], 2: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 6, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 6, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 6, 'result': None, 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 6, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 6, 'result': 0, 'errors': ['earlier'], 'active': False}, {'continue': True, 'cleanup': True, 'report': True, 'collected': ['earlier', 'recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': None, 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': 0, 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': True, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 0, 'result': 0, 'errors': [], 'active': False}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 6, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 6, 'active': False, 'handled': False, 'fatal': True})], 3: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 9, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 9, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 9, 'result': 'ok', 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': 'ok', 'errors': [], 'active': False}, {'continue': True, 'cleanup': True, 'report': False, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 9, 'result': 'ok', 'errors': [], 'active': False}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': True, 'siblings': 9, 'result': None, 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 0, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': True}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 9, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True})], 4: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 12, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 12, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 12, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 12, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': 'ok', 'errors': [], 'active': True}, {'continue': True, 'cleanup': False, 'report': False, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': False, 'siblings': 12, 'result': 'ok', 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 12, 'active': False, 'handled': False, 'fatal': True}), ({'error': None, 'failfast': True, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 12, 'result': 'ok', 'errors': [], 'active': True}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': 'ok', 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': True, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 12, 'result': 0, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': 0, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 12, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 12, 'active': False, 'handled': False, 'fatal': True})], 5: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 15, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 15, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 15, 'result': None, 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 15, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': True}, {'continue': True, 'cleanup': True, 'report': False, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': True, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': 'ok', 'errors': ['earlier'], 'active': False}, {'continue': True, 'cleanup': True, 'report': False, 'collected': ['earlier'], 'handler_call': False, 'value': 'ok', 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'recoverable', 'failfast': False, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': True, 'siblings': 15, 'result': 0, 'errors': ['earlier'], 'active': True}, {'continue': True, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 0, 'active': True, 'handled': True, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': True, 'siblings': 15, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 15, 'active': False, 'handled': False, 'fatal': True}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 15, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 15, 'active': False, 'handled': False, 'fatal': 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:
Falsey callback results are converted to absent results; the returned lifecycle plan violates the stated transition contract.

Plan callback failure handling. Recoverable callback errors are collected and sibling callbacks continue unless fail-fast was selected. Fatal failures stop immediately. Cleanup always runs for acquired callback resources. Report an unhandled error once; a configured error listener consumes a recoverable error. A callback return value remains distinct from an exception. 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: continue = s['error']!='fatal' and not(s['error'] is not None and s['failfast']); cleanup = s['acquired'] and not s['cleanup_done']; report = s['error'] is not None and not s['reported'] and (not s['handler'] or s['error']=='fatal'); collected = list(s['errors'])+([s['error']] if s['error'] is not None else []); handler_call = s['handler'] and s['error']=='recoverable'; value = s['result'] if s['error'] is None else None; remaining = s['siblings'] if s['error']=='fatal' or (s['error'] is not None and s['failfast']) else 0; active = s['active'] and s['error']!='fatal'; handled = s['handler'] and s['error']=='recoverable' and not s['failfast']; fatal = s['error']=='fatal'

split: open-access


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

N = 1
observations = []
def solve(s):
    return {
        'continue': s['error']!='fatal' and not(s['error'] is not None and s['failfast']),
        'cleanup': s['acquired'] and not s['cleanup_done'],
        'report': s['error'] is not None and not s['reported'] and (not s['handler'] or s['error']=='fatal'),
        'collected': list(s['errors'])+([s['error']] if s['error'] is not None else []),
        'handler_call': s['handler'] and s['error']=='recoverable',
        'value': s['result'] if s['error'] is None else None,
        'remaining': 0,
        'active': s['active'] and s['error']!='fatal',
        'handled': s['handler'] and s['error']=='recoverable' and not s['failfast'],
        'fatal': s['error']=='fatal',
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 3, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 3, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 3, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 3, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': True, 'cleanup': False, 'report': True, 'collected': ['earlier', 'recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'recoverable', 'failfast': True, 'handler': False, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': None, 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['earlier', 'recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': 'ok', 'errors': [], 'active': False}, {'continue': True, 'cleanup': True, 'report': False, 'collected': [], 'handler_call': False, 'value': 'ok', 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 3, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 3, 'active': False, 'handled': False, 'fatal': True})], 2: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 6, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 6, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 6, 'result': None, 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 6, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 6, 'result': 0, 'errors': ['earlier'], 'active': False}, {'continue': True, 'cleanup': True, 'report': True, 'collected': ['earlier', 'recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': None, 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': 0, 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': True, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 0, 'result': 0, 'errors': [], 'active': False}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 6, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 6, 'active': False, 'handled': False, 'fatal': True})], 3: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 9, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 9, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 9, 'result': 'ok', 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': 'ok', 'errors': [], 'active': False}, {'continue': True, 'cleanup': True, 'report': False, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 9, 'result': 'ok', 'errors': [], 'active': False}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': True, 'siblings': 9, 'result': None, 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 0, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': True}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 9, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True})], 4: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 12, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 12, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 12, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 12, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': 'ok', 'errors': [], 'active': True}, {'continue': True, 'cleanup': False, 'report': False, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': False, 'siblings': 12, 'result': 'ok', 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 12, 'active': False, 'handled': False, 'fatal': True}), ({'error': None, 'failfast': True, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 12, 'result': 'ok', 'errors': [], 'active': True}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': 'ok', 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': True, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 12, 'result': 0, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': 0, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 12, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 12, 'active': False, 'handled': False, 'fatal': True})], 5: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 15, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 15, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 15, 'result': None, 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 15, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': True}, {'continue': True, 'cleanup': True, 'report': False, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': True, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': 'ok', 'errors': ['earlier'], 'active': False}, {'continue': True, 'cleanup': True, 'report': False, 'collected': ['earlier'], 'handler_call': False, 'value': 'ok', 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'recoverable', 'failfast': False, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': True, 'siblings': 15, 'result': 0, 'errors': ['earlier'], 'active': True}, {'continue': True, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 0, 'active': True, 'handled': True, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': True, 'siblings': 15, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 15, 'active': False, 'handled': False, 'fatal': True}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 15, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 15, 'active': False, 'handled': False, 'fatal': 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 {
        'continue': s['error']!='fatal' and not(s['error'] is not None and s['failfast']),
        'cleanup': s['acquired'] and not s['cleanup_done'],
        'report': s['error'] is not None and not s['reported'] and (not s['handler'] or s['error']=='fatal'),
        'collected': list(s['errors'])+([s['error']] if s['error'] is not None else []),
        'handler_call': s['handler'] and s['error']=='recoverable',
        'value': s['result'] if s['error'] is None else None,
        'remaining': s['siblings'] if s['failfast'] else 0,
        'active': s['active'] and s['error']!='fatal',
        'handled': s['handler'] and s['error']=='recoverable' and not s['failfast'],
        'fatal': s['error']=='fatal',
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 3, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 3, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 3, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 3, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': True, 'cleanup': False, 'report': True, 'collected': ['earlier', 'recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'recoverable', 'failfast': True, 'handler': False, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': None, 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['earlier', 'recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': 'ok', 'errors': [], 'active': False}, {'continue': True, 'cleanup': True, 'report': False, 'collected': [], 'handler_call': False, 'value': 'ok', 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 3, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 3, 'active': False, 'handled': False, 'fatal': True})], 2: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 6, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 6, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 6, 'result': None, 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 6, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 6, 'result': 0, 'errors': ['earlier'], 'active': False}, {'continue': True, 'cleanup': True, 'report': True, 'collected': ['earlier', 'recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': None, 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': 0, 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': True, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 0, 'result': 0, 'errors': [], 'active': False}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 6, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 6, 'active': False, 'handled': False, 'fatal': True})], 3: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 9, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 9, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 9, 'result': 'ok', 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': 'ok', 'errors': [], 'active': False}, {'continue': True, 'cleanup': True, 'report': False, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 9, 'result': 'ok', 'errors': [], 'active': False}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': True, 'siblings': 9, 'result': None, 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 0, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': True, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': True}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 9, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 9, 'active': False, 'handled': False, 'fatal': True})], 4: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': False, 'siblings': 12, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 12, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 12, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 12, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 0, 'result': 'ok', 'errors': [], 'active': True}, {'continue': True, 'cleanup': False, 'report': False, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': False, 'siblings': 12, 'result': 'ok', 'errors': ['earlier'], 'active': False}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 12, 'active': False, 'handled': False, 'fatal': True}), ({'error': None, 'failfast': True, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 12, 'result': 'ok', 'errors': [], 'active': True}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': 'ok', 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': True, 'handler': True, 'reported': False, 'acquired': False, 'cleanup_done': True, 'siblings': 12, 'result': 0, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': 0, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 12, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 12, 'active': False, 'handled': False, 'fatal': True})], 5: [({'error': 'recoverable', 'failfast': True, 'handler': True, 'reported': False, 'acquired': True, 'cleanup_done': True, 'siblings': 15, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 15, 'active': True, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 15, 'result': None, 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': True, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 15, 'active': False, 'handled': False, 'fatal': True}), ({'error': 'recoverable', 'failfast': False, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': True}, {'continue': True, 'cleanup': True, 'report': False, 'collected': ['recoverable'], 'handler_call': False, 'value': None, 'remaining': 0, 'active': True, 'handled': False, 'fatal': False}), ({'error': None, 'failfast': True, 'handler': False, 'reported': True, 'acquired': True, 'cleanup_done': False, 'siblings': 0, 'result': 'ok', 'errors': ['earlier'], 'active': False}, {'continue': True, 'cleanup': True, 'report': False, 'collected': ['earlier'], 'handler_call': False, 'value': 'ok', 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'recoverable', 'failfast': False, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': True, 'siblings': 15, 'result': 0, 'errors': ['earlier'], 'active': True}, {'continue': True, 'cleanup': False, 'report': False, 'collected': ['earlier', 'recoverable'], 'handler_call': True, 'value': None, 'remaining': 0, 'active': True, 'handled': True, 'fatal': False}), ({'error': 'fatal', 'failfast': False, 'handler': True, 'reported': True, 'acquired': False, 'cleanup_done': True, 'siblings': 15, 'result': 0, 'errors': [], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['fatal'], 'handler_call': False, 'value': None, 'remaining': 15, 'active': False, 'handled': False, 'fatal': True}), ({'error': None, 'failfast': False, 'handler': False, 'reported': False, 'acquired': False, 'cleanup_done': False, 'siblings': 0, 'result': None, 'errors': [], 'active': False}, {'continue': True, 'cleanup': False, 'report': False, 'collected': [], 'handler_call': False, 'value': None, 'remaining': 0, 'active': False, 'handled': False, 'fatal': False}), ({'error': 'fatal', 'failfast': True, 'handler': True, 'reported': True, 'acquired': True, 'cleanup_done': True, 'siblings': 15, 'result': 'ok', 'errors': ['earlier'], 'active': True}, {'continue': False, 'cleanup': False, 'report': False, 'collected': ['earlier', 'fatal'], 'handler_call': False, 'value': None, 'remaining': 15, 'active': False, 'handled': False, 'fatal': 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:
Failure accounting claims skipped siblings executed; the returned lifecycle plan violates the stated transition contract.

Plan callback failure handling. Recoverable callback errors are collected and sibling callbacks continue unless fail-fast was selected. Fatal failures stop immediately. Cleanup always runs for acquired callback resources. Report an unhandled error once; a configured error listener consumes a recoverable error. A callback return value remains distinct from an exception. 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: continue = s['error']!='fatal' and not(s['error'] is not None and s['failfast']); cleanup = s['acquired'] and not s['cleanup_done']; report = s['error'] is not None and not s['reported'] and (not s['handler'] or s['error']=='fatal'); collected = list(s['errors'])+([s['error']] if s['error'] is not None else []); handler_call = s['handler'] and s['error']=='recoverable'; value = s['result'] if s['error'] is None else None; remaining = s['siblings'] if s['error']=='fatal' or (s['error'] is not None and s['failfast']) else 0; active = s['active'] and s['error']!='fatal'; handled = s['handler'] and s['error']=='recoverable' and not s['failfast']; fatal = s['error']=='fatal'

split: open-access