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 = {'tx_open': phase not in ('send_closed','closing','closed'), 'rx_open': phase not in ('receive_closed','closing','closed'), 'received': [], 'sent': [], 'owned': phase!='closed', 'fin_pending': phase in ('send_closed','closing'), 'payload_pending': payload[:]}
    frames = []
    observed = []
    table = {('open', 'local_eof'): ('send_closed', 'send_fin'), ('open', 'remote_fin'): ('closed', 'drop_both'), ('send_closed', 'fin_receipt'): ('send_closed', 'retire_fin'), ('receive_closed', 'local_data'): ('receive_closed', 'send'), ('send_closed', 'remote_fin'): ('closing', 'ack_fin'), ('receive_closed', 'local_eof'): ('closing', 'send_fin'), ('closing', 'fin_confirmed'): ('closed', 'release'), ('closed', 'late_data'): ('closed', 'reject'), ('send_closed', 'local_data'): ('send_closed', 'reject'), ('receive_closed', 'remote_data'): ('receive_closed', 'reject')}
    for event in events:
        phase, action = table.get((phase, event), (phase, "reject"))
        if action == 'send_fin':
            r['tx_open']=False; frames.append(['FIN',seed])
        elif action == 'send_two_fins':
            r['tx_open']=False; frames.extend([['FIN',seed],['FIN',seed]])
        elif action == 'send_fin_as_data':
            r['tx_open']=False; frames.append(['DATA',['FIN',seed]])
        elif action == 'retire_fin':
            r['fin_pending']=False
        elif action == 'retire_payload_too':
            r['fin_pending']=False; r['payload_pending']=[]
        elif action == 'ack_fin':
            r['rx_open']=False; frames.append(['ACK_FIN',seed])
        elif action == 'deliver':
            r['received'].extend(payload)
        elif action == 'send':
            r['sent'].extend(payload)
        elif action == 'release':
            r['owned']=False
        elif action == 'reject':
            frames.append(['REJECT',event])
        elif action == 'drop_both':
            r['tx_open']=False; r['rx_open']=False; r['owned']=False
        elif action == 'discard':
            r['received']=[]; r['sent']=[]
        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: [('open/local_eof', 'open', ['local_eof'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1]]}]), ('open/remote_fin', 'open', ['remote_fin'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['ACK_FIN', 1]]}]), ('send_closed/fin_receipt', 'send_closed', ['fin_receipt'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': []}]), ('receive_closed/local_data', 'receive_closed', ['local_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [1, 2, 3], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': []}]), ('send_closed/remote_fin', 'send_closed', ['remote_fin'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [1, 2, 3]}, 'frames': [['ACK_FIN', 1]]}]), ('receive_closed/local_eof', 'receive_closed', ['local_eof'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1]]}]), ('closing/fin_confirmed', 'closing', ['fin_confirmed'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': True, 'payload_pending': [1, 2, 3]}, 'frames': []}]), ('closed/late_data', 'closed', ['late_data'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['REJECT', 'late_data']]}]), ('send_closed/local_data', 'send_closed', ['local_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [1, 2, 3]}, 'frames': [['REJECT', 'local_data']]}]), ('receive_closed/remote_data', 'receive_closed', ['remote_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['REJECT', 'remote_data']]}]), ('ordered trace 0', 'open', ['local_eof', 'remote_fin', 'fin_confirmed', 'late_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1]]}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1], ['ACK_FIN', 1]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1], ['ACK_FIN', 1]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1], ['ACK_FIN', 1], ['REJECT', 'late_data']]}]), ('ordered trace 3', 'receive_closed', ['local_data', 'local_eof', 'fin_confirmed', 'late_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [1, 2, 3], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': []}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [1, 2, 3], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [1, 2, 3], 'owned': False, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [1, 2, 3], 'owned': False, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1], ['REJECT', 'late_data']]}]), ('empty input', 'open', [], []), ('unknown event', 'open', ['unsupported'], [{'phase': 'open', 'registers': {'tx_open': True, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['REJECT', 'unsupported']]}])], 2: [('open/local_eof', 'open', ['local_eof'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2]]}]), ('open/remote_fin', 'open', ['remote_fin'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['ACK_FIN', 2]]}]), ('send_closed/fin_receipt', 'send_closed', ['fin_receipt'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': []}]), ('receive_closed/local_data', 'receive_closed', ['local_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [2, 3, 4, 5], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': []}]), ('send_closed/remote_fin', 'send_closed', ['remote_fin'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['ACK_FIN', 2]]}]), ('receive_closed/local_eof', 'receive_closed', ['local_eof'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2]]}]), ('closing/fin_confirmed', 'closing', ['fin_confirmed'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': True, 'payload_pending': [2, 3, 4, 5]}, 'frames': []}]), ('closed/late_data', 'closed', ['late_data'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['REJECT', 'late_data']]}]), ('send_closed/local_data', 'send_closed', ['local_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['REJECT', 'local_data']]}]), ('receive_closed/remote_data', 'receive_closed', ['remote_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['REJECT', 'remote_data']]}]), ('ordered trace 0', 'open', ['local_eof', 'remote_fin', 'fin_confirmed', 'late_data', 'late_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2]]}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2], ['ACK_FIN', 2]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2], ['ACK_FIN', 2]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2], ['ACK_FIN', 2], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2], ['ACK_FIN', 2], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('ordered trace 3', 'receive_closed', ['local_data', 'local_eof', 'fin_confirmed', 'late_data', 'late_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [2, 3, 4, 5], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': []}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [2, 3, 4, 5], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [2, 3, 4, 5], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [2, 3, 4, 5], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [2, 3, 4, 5], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('empty input', 'open', [], []), ('unknown event', 'open', ['unsupported'], [{'phase': 'open', 'registers': {'tx_open': True, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['REJECT', 'unsupported']]}])], 3: [('open/local_eof', 'open', ['local_eof'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3]]}]), ('open/remote_fin', 'open', ['remote_fin'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['ACK_FIN', 3]]}]), ('send_closed/fin_receipt', 'send_closed', ['fin_receipt'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': []}]), ('receive_closed/local_data', 'receive_closed', ['local_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': []}]), ('send_closed/remote_fin', 'send_closed', ['remote_fin'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['ACK_FIN', 3]]}]), ('receive_closed/local_eof', 'receive_closed', ['local_eof'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3]]}]), ('closing/fin_confirmed', 'closing', ['fin_confirmed'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': True, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': []}]), ('closed/late_data', 'closed', ['late_data'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['REJECT', 'late_data']]}]), ('send_closed/local_data', 'send_closed', ['local_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['REJECT', 'local_data']]}]), ('receive_closed/remote_data', 'receive_closed', ['remote_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['REJECT', 'remote_data']]}]), ('ordered trace 0', 'open', ['local_eof', 'remote_fin', 'fin_confirmed', 'late_data', 'late_data', 'late_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3]]}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['ACK_FIN', 3]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['ACK_FIN', 3]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['ACK_FIN', 3], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['ACK_FIN', 3], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['ACK_FIN', 3], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('ordered trace 3', 'receive_closed', ['local_data', 'local_eof', 'fin_confirmed', 'late_data', 'late_data', 'late_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': []}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('empty input', 'open', [], []), ('unknown event', 'open', ['unsupported'], [{'phase': 'open', 'registers': {'tx_open': True, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['REJECT', 'unsupported']]}])], 4: [('open/local_eof', 'open', ['local_eof'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4]]}]), ('open/remote_fin', 'open', ['remote_fin'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['ACK_FIN', 4]]}]), ('send_closed/fin_receipt', 'send_closed', ['fin_receipt'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': []}]), ('receive_closed/local_data', 'receive_closed', ['local_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': []}]), ('send_closed/remote_fin', 'send_closed', ['remote_fin'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['ACK_FIN', 4]]}]), ('receive_closed/local_eof', 'receive_closed', ['local_eof'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4]]}]), ('closing/fin_confirmed', 'closing', ['fin_confirmed'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': True, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': []}]), ('closed/late_data', 'closed', ['late_data'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['REJECT', 'late_data']]}]), ('send_closed/local_data', 'send_closed', ['local_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['REJECT', 'local_data']]}]), ('receive_closed/remote_data', 'receive_closed', ['remote_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['REJECT', 'remote_data']]}]), ('ordered trace 0', 'open', ['local_eof', 'remote_fin', 'fin_confirmed', 'late_data', 'late_data', 'late_data', 'late_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4]]}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['ACK_FIN', 4]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['ACK_FIN', 4]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['ACK_FIN', 4], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['ACK_FIN', 4], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['ACK_FIN', 4], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['ACK_FIN', 4], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('ordered trace 3', 'receive_closed', ['local_data', 'local_eof', 'fin_confirmed', 'late_data', 'late_data', 'late_data', 'late_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': []}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('empty input', 'open', [], []), ('unknown event', 'open', ['unsupported'], [{'phase': 'open', 'registers': {'tx_open': True, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['REJECT', 'unsupported']]}])], 5: [('open/local_eof', 'open', ['local_eof'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5]]}]), ('open/remote_fin', 'open', ['remote_fin'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['ACK_FIN', 5]]}]), ('send_closed/fin_receipt', 'send_closed', ['fin_receipt'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': []}]), ('receive_closed/local_data', 'receive_closed', ['local_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': []}]), ('send_closed/remote_fin', 'send_closed', ['remote_fin'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['ACK_FIN', 5]]}]), ('receive_closed/local_eof', 'receive_closed', ['local_eof'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5]]}]), ('closing/fin_confirmed', 'closing', ['fin_confirmed'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': True, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': []}]), ('closed/late_data', 'closed', ['late_data'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['REJECT', 'late_data']]}]), ('send_closed/local_data', 'send_closed', ['local_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['REJECT', 'local_data']]}]), ('receive_closed/remote_data', 'receive_closed', ['remote_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['REJECT', 'remote_data']]}]), ('ordered trace 0', 'open', ['local_eof', 'remote_fin', 'fin_confirmed', 'late_data', 'late_data', 'late_data', 'late_data', 'late_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5]]}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('ordered trace 3', 'receive_closed', ['local_data', 'local_eof', 'fin_confirmed', 'late_data', 'late_data', 'late_data', 'late_data', 'late_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': []}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('empty input', 'open', [], []), ('unknown event', 'open', ['unsupported'], [{'phase': 'open', 'registers': {'tx_open': True, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['REJECT', 'unsupported']]}])]}
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 = {'tx_open': phase not in ('send_closed','closing','closed'), 'rx_open': phase not in ('receive_closed','closing','closed'), 'received': [], 'sent': [], 'owned': phase!='closed', 'fin_pending': phase in ('send_closed','closing'), 'payload_pending': payload[:]}
    frames = []
    observed = []
    table = {('open', 'local_eof'): ('send_closed', 'send_fin'), ('open', 'remote_fin'): ('open', 'ack_fin'), ('send_closed', 'fin_receipt'): ('send_closed', 'retire_fin'), ('receive_closed', 'local_data'): ('receive_closed', 'send'), ('send_closed', 'remote_fin'): ('closing', 'ack_fin'), ('receive_closed', 'local_eof'): ('closing', 'send_fin'), ('closing', 'fin_confirmed'): ('closed', 'release'), ('closed', 'late_data'): ('closed', 'reject'), ('send_closed', 'local_data'): ('send_closed', 'reject'), ('receive_closed', 'remote_data'): ('receive_closed', 'reject')}
    for event in events:
        phase, action = table.get((phase, event), (phase, "reject"))
        if action == 'send_fin':
            r['tx_open']=False; frames.append(['FIN',seed])
        elif action == 'send_two_fins':
            r['tx_open']=False; frames.extend([['FIN',seed],['FIN',seed]])
        elif action == 'send_fin_as_data':
            r['tx_open']=False; frames.append(['DATA',['FIN',seed]])
        elif action == 'retire_fin':
            r['fin_pending']=False
        elif action == 'retire_payload_too':
            r['fin_pending']=False; r['payload_pending']=[]
        elif action == 'ack_fin':
            r['rx_open']=False; frames.append(['ACK_FIN',seed])
        elif action == 'deliver':
            r['received'].extend(payload)
        elif action == 'send':
            r['sent'].extend(payload)
        elif action == 'release':
            r['owned']=False
        elif action == 'reject':
            frames.append(['REJECT',event])
        elif action == 'drop_both':
            r['tx_open']=False; r['rx_open']=False; r['owned']=False
        elif action == 'discard':
            r['received']=[]; r['sent']=[]
        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: [('open/local_eof', 'open', ['local_eof'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1]]}]), ('open/remote_fin', 'open', ['remote_fin'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['ACK_FIN', 1]]}]), ('send_closed/fin_receipt', 'send_closed', ['fin_receipt'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': []}]), ('receive_closed/local_data', 'receive_closed', ['local_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [1, 2, 3], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': []}]), ('send_closed/remote_fin', 'send_closed', ['remote_fin'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [1, 2, 3]}, 'frames': [['ACK_FIN', 1]]}]), ('receive_closed/local_eof', 'receive_closed', ['local_eof'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1]]}]), ('closing/fin_confirmed', 'closing', ['fin_confirmed'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': True, 'payload_pending': [1, 2, 3]}, 'frames': []}]), ('closed/late_data', 'closed', ['late_data'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['REJECT', 'late_data']]}]), ('send_closed/local_data', 'send_closed', ['local_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [1, 2, 3]}, 'frames': [['REJECT', 'local_data']]}]), ('receive_closed/remote_data', 'receive_closed', ['remote_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['REJECT', 'remote_data']]}]), ('ordered trace 0', 'open', ['local_eof', 'remote_fin', 'fin_confirmed', 'late_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1]]}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1], ['ACK_FIN', 1]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1], ['ACK_FIN', 1]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1], ['ACK_FIN', 1], ['REJECT', 'late_data']]}]), ('ordered trace 3', 'receive_closed', ['local_data', 'local_eof', 'fin_confirmed', 'late_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [1, 2, 3], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': []}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [1, 2, 3], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [1, 2, 3], 'owned': False, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [1, 2, 3], 'owned': False, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['FIN', 1], ['REJECT', 'late_data']]}]), ('empty input', 'open', [], []), ('unknown event', 'open', ['unsupported'], [{'phase': 'open', 'registers': {'tx_open': True, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [1, 2, 3]}, 'frames': [['REJECT', 'unsupported']]}])], 2: [('open/local_eof', 'open', ['local_eof'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2]]}]), ('open/remote_fin', 'open', ['remote_fin'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['ACK_FIN', 2]]}]), ('send_closed/fin_receipt', 'send_closed', ['fin_receipt'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': []}]), ('receive_closed/local_data', 'receive_closed', ['local_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [2, 3, 4, 5], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': []}]), ('send_closed/remote_fin', 'send_closed', ['remote_fin'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['ACK_FIN', 2]]}]), ('receive_closed/local_eof', 'receive_closed', ['local_eof'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2]]}]), ('closing/fin_confirmed', 'closing', ['fin_confirmed'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': True, 'payload_pending': [2, 3, 4, 5]}, 'frames': []}]), ('closed/late_data', 'closed', ['late_data'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['REJECT', 'late_data']]}]), ('send_closed/local_data', 'send_closed', ['local_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['REJECT', 'local_data']]}]), ('receive_closed/remote_data', 'receive_closed', ['remote_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['REJECT', 'remote_data']]}]), ('ordered trace 0', 'open', ['local_eof', 'remote_fin', 'fin_confirmed', 'late_data', 'late_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2]]}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2], ['ACK_FIN', 2]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2], ['ACK_FIN', 2]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2], ['ACK_FIN', 2], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2], ['ACK_FIN', 2], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('ordered trace 3', 'receive_closed', ['local_data', 'local_eof', 'fin_confirmed', 'late_data', 'late_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [2, 3, 4, 5], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': []}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [2, 3, 4, 5], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [2, 3, 4, 5], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [2, 3, 4, 5], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [2, 3, 4, 5], 'owned': False, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['FIN', 2], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('empty input', 'open', [], []), ('unknown event', 'open', ['unsupported'], [{'phase': 'open', 'registers': {'tx_open': True, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [2, 3, 4, 5]}, 'frames': [['REJECT', 'unsupported']]}])], 3: [('open/local_eof', 'open', ['local_eof'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3]]}]), ('open/remote_fin', 'open', ['remote_fin'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['ACK_FIN', 3]]}]), ('send_closed/fin_receipt', 'send_closed', ['fin_receipt'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': []}]), ('receive_closed/local_data', 'receive_closed', ['local_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': []}]), ('send_closed/remote_fin', 'send_closed', ['remote_fin'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['ACK_FIN', 3]]}]), ('receive_closed/local_eof', 'receive_closed', ['local_eof'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3]]}]), ('closing/fin_confirmed', 'closing', ['fin_confirmed'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': True, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': []}]), ('closed/late_data', 'closed', ['late_data'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['REJECT', 'late_data']]}]), ('send_closed/local_data', 'send_closed', ['local_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['REJECT', 'local_data']]}]), ('receive_closed/remote_data', 'receive_closed', ['remote_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['REJECT', 'remote_data']]}]), ('ordered trace 0', 'open', ['local_eof', 'remote_fin', 'fin_confirmed', 'late_data', 'late_data', 'late_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3]]}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['ACK_FIN', 3]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['ACK_FIN', 3]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['ACK_FIN', 3], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['ACK_FIN', 3], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['ACK_FIN', 3], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('ordered trace 3', 'receive_closed', ['local_data', 'local_eof', 'fin_confirmed', 'late_data', 'late_data', 'late_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': []}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [3, 4, 5, 6, 7], 'owned': False, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['FIN', 3], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('empty input', 'open', [], []), ('unknown event', 'open', ['unsupported'], [{'phase': 'open', 'registers': {'tx_open': True, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [3, 4, 5, 6, 7]}, 'frames': [['REJECT', 'unsupported']]}])], 4: [('open/local_eof', 'open', ['local_eof'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4]]}]), ('open/remote_fin', 'open', ['remote_fin'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['ACK_FIN', 4]]}]), ('send_closed/fin_receipt', 'send_closed', ['fin_receipt'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': []}]), ('receive_closed/local_data', 'receive_closed', ['local_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': []}]), ('send_closed/remote_fin', 'send_closed', ['remote_fin'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['ACK_FIN', 4]]}]), ('receive_closed/local_eof', 'receive_closed', ['local_eof'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4]]}]), ('closing/fin_confirmed', 'closing', ['fin_confirmed'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': True, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': []}]), ('closed/late_data', 'closed', ['late_data'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['REJECT', 'late_data']]}]), ('send_closed/local_data', 'send_closed', ['local_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['REJECT', 'local_data']]}]), ('receive_closed/remote_data', 'receive_closed', ['remote_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['REJECT', 'remote_data']]}]), ('ordered trace 0', 'open', ['local_eof', 'remote_fin', 'fin_confirmed', 'late_data', 'late_data', 'late_data', 'late_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4]]}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['ACK_FIN', 4]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['ACK_FIN', 4]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['ACK_FIN', 4], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['ACK_FIN', 4], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['ACK_FIN', 4], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['ACK_FIN', 4], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('ordered trace 3', 'receive_closed', ['local_data', 'local_eof', 'fin_confirmed', 'late_data', 'late_data', 'late_data', 'late_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': []}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [4, 5, 6, 7, 8, 9], 'owned': False, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['FIN', 4], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('empty input', 'open', [], []), ('unknown event', 'open', ['unsupported'], [{'phase': 'open', 'registers': {'tx_open': True, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [4, 5, 6, 7, 8, 9]}, 'frames': [['REJECT', 'unsupported']]}])], 5: [('open/local_eof', 'open', ['local_eof'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5]]}]), ('open/remote_fin', 'open', ['remote_fin'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['ACK_FIN', 5]]}]), ('send_closed/fin_receipt', 'send_closed', ['fin_receipt'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': []}]), ('receive_closed/local_data', 'receive_closed', ['local_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': []}]), ('send_closed/remote_fin', 'send_closed', ['remote_fin'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['ACK_FIN', 5]]}]), ('receive_closed/local_eof', 'receive_closed', ['local_eof'], [{'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5]]}]), ('closing/fin_confirmed', 'closing', ['fin_confirmed'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': True, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': []}]), ('closed/late_data', 'closed', ['late_data'], [{'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['REJECT', 'late_data']]}]), ('send_closed/local_data', 'send_closed', ['local_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': True, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['REJECT', 'local_data']]}]), ('receive_closed/remote_data', 'receive_closed', ['remote_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['REJECT', 'remote_data']]}]), ('ordered trace 0', 'open', ['local_eof', 'remote_fin', 'fin_confirmed', 'late_data', 'late_data', 'late_data', 'late_data', 'late_data'], [{'phase': 'send_closed', 'registers': {'tx_open': False, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5]]}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['ACK_FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('ordered trace 3', 'receive_closed', ['local_data', 'local_eof', 'fin_confirmed', 'late_data', 'late_data', 'late_data', 'late_data', 'late_data'], [{'phase': 'receive_closed', 'registers': {'tx_open': True, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': []}, {'phase': 'closing', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5]]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}, {'phase': 'closed', 'registers': {'tx_open': False, 'rx_open': False, 'received': [], 'sent': [5, 6, 7, 8, 9, 10, 11], 'owned': False, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['FIN', 5], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data'], ['REJECT', 'late_data']]}]), ('empty input', 'open', [], []), ('unknown event', 'open', ['unsupported'], [{'phase': 'open', 'registers': {'tx_open': True, 'rx_open': True, 'received': [], 'sent': [], 'owned': True, 'fin_pending': False, 'payload_pending': [5, 6, 7, 8, 9, 10, 11]}, 'frames': [['REJECT', 'unsupported']]}])]}
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 open, event remote_fin produces closed/drop_both instead of receive_closed/ack_fin.

For the stipulated Bidirectional orderly-close 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