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

N = 1
observations = []
def solve(phase, events, seed):
    payload = list(range(seed, seed * 2 + 2))
    r = {'channel': seed, 'allocated': int(phase!='absent'), 'ready_notifications': int(phase=='ready'), 'delivered': [], 'producer_error': None, 'policy_checks': 0}
    frames = []
    observed = []
    table = {('absent', 'open_local'): ('pending', 'send_open'), ('pending', 'accepted'): ('ready', 'notify_ready'), ('pending', 'refused'): ('absent', 'notify_refused'), ('absent', 'open_remote'): ('ready', 'accept'), ('checking', 'allowed'): ('ready', 'accept'), ('checking', 'denied'): ('absent', 'refuse'), ('pending', 'data'): ('pending', 'reject'), ('ready', 'reset'): ('absent', 'notify_reset'), ('ready', 'duplicate_open'): ('ready', 'repeat_accept'), ('absent', 'accepted'): ('absent', 'reject')}
    for event in events:
        phase, action = table.get((phase, event), (phase, "reject"))
        if action == 'send_open':
            frames.append(['OPEN',r['channel']])
        elif action == 'notify_ready':
            r['ready_notifications']+=1
        elif action == 'notify_refused':
            r['allocated']=0; r['producer_error']='refused'
        elif action == 'check_policy':
            r['policy_checks']+=1
        elif action == 'accept':
            frames.append(['ACCEPT',r['channel']])
        elif action == 'refuse':
            r['allocated']=0; frames.append(['REFUSE',r['channel']])
        elif action == 'reject':
            frames.append(['REJECT',r['channel']])
        elif action == 'notify_reset':
            r['allocated']=0; r['producer_error']='reset'
        elif action == 'repeat_accept':
            frames.append(['ACCEPT',r['channel']])
        elif action == 'allocate_again':
            r['allocated']+=1
        elif action == 'send_data':
            frames.append(['DATA',r['channel'],payload])
        elif action == 'deliver':
            r['delivered'].extend(payload)
        elif action == 'buffer':
            r['delivered'].extend(payload)
        else:
            if action not in ("wait", "ignore", "keep", "retain", "keep_peer", "keep_offer", "keep_hold", "keep_batch", "retain_staging", "keep_staging", "keep_local_owner", "keep_old_session", "keep_address", "keep_old_expiry", "ignore_conflict", "keep_service", "keep_subscription", "retain_shadow", "keep_live", "keep_suspicion", "keep_roles", "keep_staged"):
                frames.append([action, payload[:]])
        observed.append(json.loads(json.dumps({"phase": phase, "registers": r, "frames": frames})))
    return observed
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('absent/open_local', 'absent', ['open_local'], [{'phase': 'pending', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 1]]}]), ('pending/accepted', 'pending', ['accepted'], [{'phase': 'ready', 'registers': {'channel': 1, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': []}]), ('pending/refused', 'pending', ['refused'], [{'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': []}]), ('absent/open_remote', 'absent', ['open_remote'], [{'phase': 'checking', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 1}, 'frames': []}]), ('checking/allowed', 'checking', ['allowed'], [{'phase': 'ready', 'registers': {'channel': 1, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 1]]}]), ('checking/denied', 'checking', ['denied'], [{'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REFUSE', 1]]}]), ('pending/data', 'pending', ['data'], [{'phase': 'pending', 'registers': {'channel': 1, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 1]]}]), ('ready/reset', 'ready', ['reset'], [{'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 1, 'delivered': [], 'producer_error': 'reset', 'policy_checks': 0}, 'frames': []}]), ('ready/duplicate_open', 'ready', ['duplicate_open'], [{'phase': 'ready', 'registers': {'channel': 1, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 1]]}]), ('absent/accepted', 'absent', ['accepted'], [{'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 1]]}]), ('ordered trace 0', 'absent', ['open_local', 'refused', 'accepted', 'open_local'], [{'phase': 'pending', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 1]]}, {'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 1]]}, {'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 1], ['REJECT', 1]]}, {'phase': 'pending', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 1], ['REJECT', 1], ['OPEN', 1]]}]), ('ordered trace 3', 'absent', ['open_local', 'refused', 'accepted', 'open_local'], [{'phase': 'pending', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 1]]}, {'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 1]]}, {'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 1], ['REJECT', 1]]}, {'phase': 'pending', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 1], ['REJECT', 1], ['OPEN', 1]]}]), ('empty input', 'absent', [], []), ('unknown event', 'absent', ['unsupported'], [{'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 1]]}])], 2: [('absent/open_local', 'absent', ['open_local'], [{'phase': 'pending', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 2]]}]), ('pending/accepted', 'pending', ['accepted'], [{'phase': 'ready', 'registers': {'channel': 2, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': []}]), ('pending/refused', 'pending', ['refused'], [{'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': []}]), ('absent/open_remote', 'absent', ['open_remote'], [{'phase': 'checking', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 1}, 'frames': []}]), ('checking/allowed', 'checking', ['allowed'], [{'phase': 'ready', 'registers': {'channel': 2, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 2]]}]), ('checking/denied', 'checking', ['denied'], [{'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REFUSE', 2]]}]), ('pending/data', 'pending', ['data'], [{'phase': 'pending', 'registers': {'channel': 2, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 2]]}]), ('ready/reset', 'ready', ['reset'], [{'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 1, 'delivered': [], 'producer_error': 'reset', 'policy_checks': 0}, 'frames': []}]), ('ready/duplicate_open', 'ready', ['duplicate_open'], [{'phase': 'ready', 'registers': {'channel': 2, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 2]]}]), ('absent/accepted', 'absent', ['accepted'], [{'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 2]]}]), ('ordered trace 0', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused'], [{'phase': 'pending', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 2]]}, {'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2]]}, {'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2], ['REJECT', 2]]}, {'phase': 'pending', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2], ['REJECT', 2], ['OPEN', 2]]}, {'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2], ['REJECT', 2], ['OPEN', 2]]}]), ('ordered trace 3', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused'], [{'phase': 'pending', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 2]]}, {'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2]]}, {'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2], ['REJECT', 2]]}, {'phase': 'pending', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2], ['REJECT', 2], ['OPEN', 2]]}, {'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2], ['REJECT', 2], ['OPEN', 2]]}]), ('empty input', 'absent', [], []), ('unknown event', 'absent', ['unsupported'], [{'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 2]]}])], 3: [('absent/open_local', 'absent', ['open_local'], [{'phase': 'pending', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 3]]}]), ('pending/accepted', 'pending', ['accepted'], [{'phase': 'ready', 'registers': {'channel': 3, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': []}]), ('pending/refused', 'pending', ['refused'], [{'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': []}]), ('absent/open_remote', 'absent', ['open_remote'], [{'phase': 'checking', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 1}, 'frames': []}]), ('checking/allowed', 'checking', ['allowed'], [{'phase': 'ready', 'registers': {'channel': 3, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 3]]}]), ('checking/denied', 'checking', ['denied'], [{'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REFUSE', 3]]}]), ('pending/data', 'pending', ['data'], [{'phase': 'pending', 'registers': {'channel': 3, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 3]]}]), ('ready/reset', 'ready', ['reset'], [{'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 1, 'delivered': [], 'producer_error': 'reset', 'policy_checks': 0}, 'frames': []}]), ('ready/duplicate_open', 'ready', ['duplicate_open'], [{'phase': 'ready', 'registers': {'channel': 3, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 3]]}]), ('absent/accepted', 'absent', ['accepted'], [{'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 3]]}]), ('ordered trace 0', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused', 'accepted'], [{'phase': 'pending', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3]]}, {'phase': 'pending', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3], ['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3], ['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3], ['OPEN', 3], ['REJECT', 3]]}]), ('ordered trace 3', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused', 'accepted'], [{'phase': 'pending', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3]]}, {'phase': 'pending', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3], ['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3], ['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3], ['OPEN', 3], ['REJECT', 3]]}]), ('empty input', 'absent', [], []), ('unknown event', 'absent', ['unsupported'], [{'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 3]]}])], 4: [('absent/open_local', 'absent', ['open_local'], [{'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 4]]}]), ('pending/accepted', 'pending', ['accepted'], [{'phase': 'ready', 'registers': {'channel': 4, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': []}]), ('pending/refused', 'pending', ['refused'], [{'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': []}]), ('absent/open_remote', 'absent', ['open_remote'], [{'phase': 'checking', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 1}, 'frames': []}]), ('checking/allowed', 'checking', ['allowed'], [{'phase': 'ready', 'registers': {'channel': 4, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 4]]}]), ('checking/denied', 'checking', ['denied'], [{'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REFUSE', 4]]}]), ('pending/data', 'pending', ['data'], [{'phase': 'pending', 'registers': {'channel': 4, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 4]]}]), ('ready/reset', 'ready', ['reset'], [{'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 1, 'delivered': [], 'producer_error': 'reset', 'policy_checks': 0}, 'frames': []}]), ('ready/duplicate_open', 'ready', ['duplicate_open'], [{'phase': 'ready', 'registers': {'channel': 4, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 4]]}]), ('absent/accepted', 'absent', ['accepted'], [{'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 4]]}]), ('ordered trace 0', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused', 'accepted', 'open_local'], [{'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4]]}, {'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4], ['REJECT', 4]]}, {'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4], ['REJECT', 4], ['OPEN', 4]]}]), ('ordered trace 3', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused', 'accepted', 'open_local'], [{'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4]]}, {'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4], ['REJECT', 4]]}, {'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4], ['REJECT', 4], ['OPEN', 4]]}]), ('empty input', 'absent', [], []), ('unknown event', 'absent', ['unsupported'], [{'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 4]]}])], 5: [('absent/open_local', 'absent', ['open_local'], [{'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 5]]}]), ('pending/accepted', 'pending', ['accepted'], [{'phase': 'ready', 'registers': {'channel': 5, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': []}]), ('pending/refused', 'pending', ['refused'], [{'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': []}]), ('absent/open_remote', 'absent', ['open_remote'], [{'phase': 'checking', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 1}, 'frames': []}]), ('checking/allowed', 'checking', ['allowed'], [{'phase': 'ready', 'registers': {'channel': 5, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 5]]}]), ('checking/denied', 'checking', ['denied'], [{'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REFUSE', 5]]}]), ('pending/data', 'pending', ['data'], [{'phase': 'pending', 'registers': {'channel': 5, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 5]]}]), ('ready/reset', 'ready', ['reset'], [{'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 1, 'delivered': [], 'producer_error': 'reset', 'policy_checks': 0}, 'frames': []}]), ('ready/duplicate_open', 'ready', ['duplicate_open'], [{'phase': 'ready', 'registers': {'channel': 5, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 5]]}]), ('absent/accepted', 'absent', ['accepted'], [{'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 5]]}]), ('ordered trace 0', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused', 'accepted', 'open_local', 'refused'], [{'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5]]}, {'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5], ['REJECT', 5]]}, {'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}]), ('ordered trace 3', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused', 'accepted', 'open_local', 'refused'], [{'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5]]}, {'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5], ['REJECT', 5]]}, {'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}]), ('empty input', 'absent', [], []), ('unknown event', 'absent', ['unsupported'], [{'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 5]]}])]}
for label, phase, events, expected in cases[N]:
    check(label, solve(phase, events, N), 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(phase, events, seed):
    payload = list(range(seed, seed * 2 + 2))
    r = {'channel': seed, 'allocated': int(phase!='absent'), 'ready_notifications': int(phase=='ready'), 'delivered': [], 'producer_error': None, 'policy_checks': 0}
    frames = []
    observed = []
    table = {('absent', 'open_local'): ('pending', 'send_open'), ('pending', 'accepted'): ('ready', 'notify_ready'), ('pending', 'refused'): ('absent', 'notify_refused'), ('absent', 'open_remote'): ('absent', 'ignore'), ('checking', 'allowed'): ('ready', 'accept'), ('checking', 'denied'): ('absent', 'refuse'), ('pending', 'data'): ('pending', 'reject'), ('ready', 'reset'): ('absent', 'notify_reset'), ('ready', 'duplicate_open'): ('ready', 'repeat_accept'), ('absent', 'accepted'): ('absent', 'reject')}
    for event in events:
        phase, action = table.get((phase, event), (phase, "reject"))
        if action == 'send_open':
            frames.append(['OPEN',r['channel']])
        elif action == 'notify_ready':
            r['ready_notifications']+=1
        elif action == 'notify_refused':
            r['allocated']=0; r['producer_error']='refused'
        elif action == 'check_policy':
            r['policy_checks']+=1
        elif action == 'accept':
            frames.append(['ACCEPT',r['channel']])
        elif action == 'refuse':
            r['allocated']=0; frames.append(['REFUSE',r['channel']])
        elif action == 'reject':
            frames.append(['REJECT',r['channel']])
        elif action == 'notify_reset':
            r['allocated']=0; r['producer_error']='reset'
        elif action == 'repeat_accept':
            frames.append(['ACCEPT',r['channel']])
        elif action == 'allocate_again':
            r['allocated']+=1
        elif action == 'send_data':
            frames.append(['DATA',r['channel'],payload])
        elif action == 'deliver':
            r['delivered'].extend(payload)
        elif action == 'buffer':
            r['delivered'].extend(payload)
        else:
            if action not in ("wait", "ignore", "keep", "retain", "keep_peer", "keep_offer", "keep_hold", "keep_batch", "retain_staging", "keep_staging", "keep_local_owner", "keep_old_session", "keep_address", "keep_old_expiry", "ignore_conflict", "keep_service", "keep_subscription", "retain_shadow", "keep_live", "keep_suspicion", "keep_roles", "keep_staged"):
                frames.append([action, payload[:]])
        observed.append(json.loads(json.dumps({"phase": phase, "registers": r, "frames": frames})))
    return observed
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('absent/open_local', 'absent', ['open_local'], [{'phase': 'pending', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 1]]}]), ('pending/accepted', 'pending', ['accepted'], [{'phase': 'ready', 'registers': {'channel': 1, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': []}]), ('pending/refused', 'pending', ['refused'], [{'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': []}]), ('absent/open_remote', 'absent', ['open_remote'], [{'phase': 'checking', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 1}, 'frames': []}]), ('checking/allowed', 'checking', ['allowed'], [{'phase': 'ready', 'registers': {'channel': 1, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 1]]}]), ('checking/denied', 'checking', ['denied'], [{'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REFUSE', 1]]}]), ('pending/data', 'pending', ['data'], [{'phase': 'pending', 'registers': {'channel': 1, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 1]]}]), ('ready/reset', 'ready', ['reset'], [{'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 1, 'delivered': [], 'producer_error': 'reset', 'policy_checks': 0}, 'frames': []}]), ('ready/duplicate_open', 'ready', ['duplicate_open'], [{'phase': 'ready', 'registers': {'channel': 1, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 1]]}]), ('absent/accepted', 'absent', ['accepted'], [{'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 1]]}]), ('ordered trace 0', 'absent', ['open_local', 'refused', 'accepted', 'open_local'], [{'phase': 'pending', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 1]]}, {'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 1]]}, {'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 1], ['REJECT', 1]]}, {'phase': 'pending', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 1], ['REJECT', 1], ['OPEN', 1]]}]), ('ordered trace 3', 'absent', ['open_local', 'refused', 'accepted', 'open_local'], [{'phase': 'pending', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 1]]}, {'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 1]]}, {'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 1], ['REJECT', 1]]}, {'phase': 'pending', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 1], ['REJECT', 1], ['OPEN', 1]]}]), ('empty input', 'absent', [], []), ('unknown event', 'absent', ['unsupported'], [{'phase': 'absent', 'registers': {'channel': 1, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 1]]}])], 2: [('absent/open_local', 'absent', ['open_local'], [{'phase': 'pending', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 2]]}]), ('pending/accepted', 'pending', ['accepted'], [{'phase': 'ready', 'registers': {'channel': 2, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': []}]), ('pending/refused', 'pending', ['refused'], [{'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': []}]), ('absent/open_remote', 'absent', ['open_remote'], [{'phase': 'checking', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 1}, 'frames': []}]), ('checking/allowed', 'checking', ['allowed'], [{'phase': 'ready', 'registers': {'channel': 2, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 2]]}]), ('checking/denied', 'checking', ['denied'], [{'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REFUSE', 2]]}]), ('pending/data', 'pending', ['data'], [{'phase': 'pending', 'registers': {'channel': 2, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 2]]}]), ('ready/reset', 'ready', ['reset'], [{'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 1, 'delivered': [], 'producer_error': 'reset', 'policy_checks': 0}, 'frames': []}]), ('ready/duplicate_open', 'ready', ['duplicate_open'], [{'phase': 'ready', 'registers': {'channel': 2, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 2]]}]), ('absent/accepted', 'absent', ['accepted'], [{'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 2]]}]), ('ordered trace 0', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused'], [{'phase': 'pending', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 2]]}, {'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2]]}, {'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2], ['REJECT', 2]]}, {'phase': 'pending', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2], ['REJECT', 2], ['OPEN', 2]]}, {'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2], ['REJECT', 2], ['OPEN', 2]]}]), ('ordered trace 3', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused'], [{'phase': 'pending', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 2]]}, {'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2]]}, {'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2], ['REJECT', 2]]}, {'phase': 'pending', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2], ['REJECT', 2], ['OPEN', 2]]}, {'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 2], ['REJECT', 2], ['OPEN', 2]]}]), ('empty input', 'absent', [], []), ('unknown event', 'absent', ['unsupported'], [{'phase': 'absent', 'registers': {'channel': 2, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 2]]}])], 3: [('absent/open_local', 'absent', ['open_local'], [{'phase': 'pending', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 3]]}]), ('pending/accepted', 'pending', ['accepted'], [{'phase': 'ready', 'registers': {'channel': 3, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': []}]), ('pending/refused', 'pending', ['refused'], [{'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': []}]), ('absent/open_remote', 'absent', ['open_remote'], [{'phase': 'checking', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 1}, 'frames': []}]), ('checking/allowed', 'checking', ['allowed'], [{'phase': 'ready', 'registers': {'channel': 3, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 3]]}]), ('checking/denied', 'checking', ['denied'], [{'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REFUSE', 3]]}]), ('pending/data', 'pending', ['data'], [{'phase': 'pending', 'registers': {'channel': 3, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 3]]}]), ('ready/reset', 'ready', ['reset'], [{'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 1, 'delivered': [], 'producer_error': 'reset', 'policy_checks': 0}, 'frames': []}]), ('ready/duplicate_open', 'ready', ['duplicate_open'], [{'phase': 'ready', 'registers': {'channel': 3, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 3]]}]), ('absent/accepted', 'absent', ['accepted'], [{'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 3]]}]), ('ordered trace 0', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused', 'accepted'], [{'phase': 'pending', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3]]}, {'phase': 'pending', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3], ['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3], ['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3], ['OPEN', 3], ['REJECT', 3]]}]), ('ordered trace 3', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused', 'accepted'], [{'phase': 'pending', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3]]}, {'phase': 'pending', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3], ['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3], ['OPEN', 3]]}, {'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 3], ['REJECT', 3], ['OPEN', 3], ['REJECT', 3]]}]), ('empty input', 'absent', [], []), ('unknown event', 'absent', ['unsupported'], [{'phase': 'absent', 'registers': {'channel': 3, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 3]]}])], 4: [('absent/open_local', 'absent', ['open_local'], [{'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 4]]}]), ('pending/accepted', 'pending', ['accepted'], [{'phase': 'ready', 'registers': {'channel': 4, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': []}]), ('pending/refused', 'pending', ['refused'], [{'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': []}]), ('absent/open_remote', 'absent', ['open_remote'], [{'phase': 'checking', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 1}, 'frames': []}]), ('checking/allowed', 'checking', ['allowed'], [{'phase': 'ready', 'registers': {'channel': 4, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 4]]}]), ('checking/denied', 'checking', ['denied'], [{'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REFUSE', 4]]}]), ('pending/data', 'pending', ['data'], [{'phase': 'pending', 'registers': {'channel': 4, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 4]]}]), ('ready/reset', 'ready', ['reset'], [{'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 1, 'delivered': [], 'producer_error': 'reset', 'policy_checks': 0}, 'frames': []}]), ('ready/duplicate_open', 'ready', ['duplicate_open'], [{'phase': 'ready', 'registers': {'channel': 4, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 4]]}]), ('absent/accepted', 'absent', ['accepted'], [{'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 4]]}]), ('ordered trace 0', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused', 'accepted', 'open_local'], [{'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4]]}, {'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4], ['REJECT', 4]]}, {'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4], ['REJECT', 4], ['OPEN', 4]]}]), ('ordered trace 3', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused', 'accepted', 'open_local'], [{'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4]]}, {'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4]]}, {'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4], ['REJECT', 4]]}, {'phase': 'pending', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 4], ['REJECT', 4], ['OPEN', 4], ['REJECT', 4], ['OPEN', 4]]}]), ('empty input', 'absent', [], []), ('unknown event', 'absent', ['unsupported'], [{'phase': 'absent', 'registers': {'channel': 4, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 4]]}])], 5: [('absent/open_local', 'absent', ['open_local'], [{'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 5]]}]), ('pending/accepted', 'pending', ['accepted'], [{'phase': 'ready', 'registers': {'channel': 5, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': []}]), ('pending/refused', 'pending', ['refused'], [{'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': []}]), ('absent/open_remote', 'absent', ['open_remote'], [{'phase': 'checking', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 1}, 'frames': []}]), ('checking/allowed', 'checking', ['allowed'], [{'phase': 'ready', 'registers': {'channel': 5, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 5]]}]), ('checking/denied', 'checking', ['denied'], [{'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REFUSE', 5]]}]), ('pending/data', 'pending', ['data'], [{'phase': 'pending', 'registers': {'channel': 5, 'allocated': 1, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 5]]}]), ('ready/reset', 'ready', ['reset'], [{'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 1, 'delivered': [], 'producer_error': 'reset', 'policy_checks': 0}, 'frames': []}]), ('ready/duplicate_open', 'ready', ['duplicate_open'], [{'phase': 'ready', 'registers': {'channel': 5, 'allocated': 1, 'ready_notifications': 1, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['ACCEPT', 5]]}]), ('absent/accepted', 'absent', ['accepted'], [{'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 5]]}]), ('ordered trace 0', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused', 'accepted', 'open_local', 'refused'], [{'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5]]}, {'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5], ['REJECT', 5]]}, {'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}]), ('ordered trace 3', 'absent', ['open_local', 'refused', 'accepted', 'open_local', 'refused', 'accepted', 'open_local', 'refused'], [{'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5]]}, {'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5], ['REJECT', 5]]}, {'phase': 'pending', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}, {'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': 'refused', 'policy_checks': 0}, 'frames': [['OPEN', 5], ['REJECT', 5], ['OPEN', 5], ['REJECT', 5], ['OPEN', 5]]}]), ('empty input', 'absent', [], []), ('unknown event', 'absent', ['unsupported'], [{'phase': 'absent', 'registers': {'channel': 5, 'allocated': 0, 'ready_notifications': 0, 'delivered': [], 'producer_error': None, 'policy_checks': 0}, 'frames': [['REJECT', 5]]}])]}
for label, phase, events, expected in cases[N]:
    check(label, solve(phase, events, N), 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:
While absent, event open_remote produces ready/accept instead of checking/check_policy.

For the stipulated Multiplexed logical-channel admission controller, initialize the explicitly shown resource registers from seed (1..5), then consume classified events sequentially. After each event return a deep snapshot of phase, resource registers, and cumulative emitted control frames. The explicit ten phase/event rules and their resource effects define admission and response semantics. Unlisted events preserve phase and emit rejection. Payload is the consecutive integers seed through 2*seed+1. Empty event input returns no observations.

split: open-access