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 = {'parser': 'data' if phase in ('data','guarding') else 'command', 'partial_command': [seed-1], 'candidate': payload[:], 'delivered': [], 'queue': payload[:], 'reported': []}
    frames = []
    observed = []
    table = {('command', 'enter_data'): ('switching', 'send_mode_request'), ('switching', 'mode_ack'): ('data', 'enable_payload'), ('switching', 'mode_nack'): ('command', 'report_refused'), ('data', 'escape_guard_start'): ('command', 'parse_command'), ('guarding', 'guard_satisfied'): ('command', 'consume_escape'), ('guarding', 'guard_broken'): ('data', 'deliver_candidate_and_data'), ('command', 'payload'): ('command', 'reject_data'), ('data', 'command_like_payload'): ('data', 'deliver_verbatim'), ('data', 'hangup'): ('command', 'flush_close_report'), ('command', 'line_reset'): ('command', 'reset_parser_report')}
    for event in events:
        phase, action = table.get((phase, event), (phase, "reject"))
        if action == 'send_mode_request':
            frames.append(['ENTER_DATA',seed])
        elif action == 'enable_payload':
            r['parser']='data'
        elif action == 'report_refused':
            r['reported'].append('mode_refused')
        elif action == 'hold_escape_candidate':
            r['candidate']=payload[:]
        elif action == 'consume_escape':
            r['candidate']=[]; r['parser']='command'
        elif action == 'deliver_candidate_and_data':
            r['delivered'].extend(r['candidate']+payload); r['candidate']=[]
        elif action == 'reject_data':
            r['reported'].append('not_data_mode')
        elif action == 'deliver_verbatim':
            r['delivered'].extend(payload)
        elif action == 'flush_close_report':
            r['queue']=[]; r['reported'].append('hangup'); r['parser']='command'
        elif action == 'reset_parser_report':
            r['partial_command']=[]; r['reported'].append('reset')
        elif action == 'send_payload':
            frames.append(['DATA',payload])
        elif action == 'flush_input':
            r['partial_command']=[]
        elif action == 'keep_commands':
            r['parser']='command'
        elif action == 'keep_command_parser':
            r['parser']='command'
        elif action == 'drop_response':
            r['reported']=[]
        elif action == 'parse_command':
            r['partial_command'].extend(payload)
        elif action == 'deliver_escape':
            r['delivered'].extend(r['candidate'])
        elif action == 'drop_candidate':
            r['candidate']=[]
        elif action == 'deliver':
            r['delivered'].extend(payload)
        elif action == 'queue_forever':
            r['queue'].extend(payload)
        elif action == 'execute_command':
            frames.append(['EXECUTE',payload])
        elif action == 'strip_prefix':
            r['delivered'].extend(payload[1:])
        elif action == 'keep_payload_queue':
            r['reported'].append('hangup')
        elif action == 'retain_partial_command':
            r['reported'].append('reset')
        elif action == 'continue':
            r['queue'].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: [('command/enter_data', 'command', ['enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': [['ENTER_DATA', 1]]}]), ('switching/mode_ack', 'switching', ['mode_ack'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}]), ('switching/mode_nack', 'switching', ['mode_nack'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['mode_refused']}, 'frames': []}]), ('data/escape_guard_start', 'data', ['escape_guard_start'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}]), ('guarding/guard_satisfied', 'guarding', ['guard_satisfied'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}]), ('guarding/guard_broken', 'guarding', ['guard_broken'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [0], 'candidate': [], 'delivered': [1, 2, 3, 1, 2, 3], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}]), ('command/payload', 'command', ['payload'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['not_data_mode']}, 'frames': []}]), ('data/command_like_payload', 'data', ['command_like_payload'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [1, 2, 3], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}]), ('data/hangup', 'data', ['hangup'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [], 'reported': ['hangup']}, 'frames': []}]), ('command/line_reset', 'command', ['line_reset'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['reset']}, 'frames': []}]), ('ordered trace 0', 'command', ['enter_data', 'mode_nack', 'line_reset', 'enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': [['ENTER_DATA', 1]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['mode_refused']}, 'frames': [['ENTER_DATA', 1]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 1]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 1], ['ENTER_DATA', 1]]}]), ('ordered trace 3', 'data', ['escape_guard_start', 'guard_satisfied', 'line_reset', 'enter_data'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['reset']}, 'frames': []}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['reset']}, 'frames': [['ENTER_DATA', 1]]}]), ('empty input', 'command', [], []), ('unknown event', 'command', ['unsupported'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': [['reject', [1, 2, 3]]]}])], 2: [('command/enter_data', 'command', ['enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': [['ENTER_DATA', 2]]}]), ('switching/mode_ack', 'switching', ['mode_ack'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}]), ('switching/mode_nack', 'switching', ['mode_nack'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['mode_refused']}, 'frames': []}]), ('data/escape_guard_start', 'data', ['escape_guard_start'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}]), ('guarding/guard_satisfied', 'guarding', ['guard_satisfied'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}]), ('guarding/guard_broken', 'guarding', ['guard_broken'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [1], 'candidate': [], 'delivered': [2, 3, 4, 5, 2, 3, 4, 5], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}]), ('command/payload', 'command', ['payload'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['not_data_mode']}, 'frames': []}]), ('data/command_like_payload', 'data', ['command_like_payload'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [2, 3, 4, 5], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}]), ('data/hangup', 'data', ['hangup'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [], 'reported': ['hangup']}, 'frames': []}]), ('command/line_reset', 'command', ['line_reset'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['reset']}, 'frames': []}]), ('ordered trace 0', 'command', ['enter_data', 'mode_nack', 'line_reset', 'enter_data', 'mode_ack'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': [['ENTER_DATA', 2]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['mode_refused']}, 'frames': [['ENTER_DATA', 2]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 2]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 2], ['ENTER_DATA', 2]]}, {'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 2], ['ENTER_DATA', 2]]}]), ('ordered trace 3', 'data', ['escape_guard_start', 'guard_satisfied', 'line_reset', 'enter_data', 'mode_nack'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['reset']}, 'frames': []}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['reset']}, 'frames': [['ENTER_DATA', 2]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['reset', 'mode_refused']}, 'frames': [['ENTER_DATA', 2]]}]), ('empty input', 'command', [], []), ('unknown event', 'command', ['unsupported'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': [['reject', [2, 3, 4, 5]]]}])], 3: [('command/enter_data', 'command', ['enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': [['ENTER_DATA', 3]]}]), ('switching/mode_ack', 'switching', ['mode_ack'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}]), ('switching/mode_nack', 'switching', ['mode_nack'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['mode_refused']}, 'frames': []}]), ('data/escape_guard_start', 'data', ['escape_guard_start'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}]), ('guarding/guard_satisfied', 'guarding', ['guard_satisfied'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}]), ('guarding/guard_broken', 'guarding', ['guard_broken'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [2], 'candidate': [], 'delivered': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}]), ('command/payload', 'command', ['payload'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['not_data_mode']}, 'frames': []}]), ('data/command_like_payload', 'data', ['command_like_payload'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [3, 4, 5, 6, 7], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}]), ('data/hangup', 'data', ['hangup'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [], 'reported': ['hangup']}, 'frames': []}]), ('command/line_reset', 'command', ['line_reset'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['reset']}, 'frames': []}]), ('ordered trace 0', 'command', ['enter_data', 'mode_nack', 'line_reset', 'enter_data', 'mode_ack', 'hangup'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': [['ENTER_DATA', 3]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['mode_refused']}, 'frames': [['ENTER_DATA', 3]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 3]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 3], ['ENTER_DATA', 3]]}, {'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 3], ['ENTER_DATA', 3]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [], 'reported': ['mode_refused', 'reset', 'hangup']}, 'frames': [['ENTER_DATA', 3], ['ENTER_DATA', 3]]}]), ('ordered trace 3', 'data', ['escape_guard_start', 'guard_satisfied', 'line_reset', 'enter_data', 'mode_nack', 'line_reset'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['reset']}, 'frames': []}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['reset']}, 'frames': [['ENTER_DATA', 3]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['reset', 'mode_refused']}, 'frames': [['ENTER_DATA', 3]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['reset', 'mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 3]]}]), ('empty input', 'command', [], []), ('unknown event', 'command', ['unsupported'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': [['reject', [3, 4, 5, 6, 7]]]}])], 4: [('command/enter_data', 'command', ['enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': [['ENTER_DATA', 4]]}]), ('switching/mode_ack', 'switching', ['mode_ack'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}]), ('switching/mode_nack', 'switching', ['mode_nack'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['mode_refused']}, 'frames': []}]), ('data/escape_guard_start', 'data', ['escape_guard_start'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}]), ('guarding/guard_satisfied', 'guarding', ['guard_satisfied'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}]), ('guarding/guard_broken', 'guarding', ['guard_broken'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [3], 'candidate': [], 'delivered': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}]), ('command/payload', 'command', ['payload'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['not_data_mode']}, 'frames': []}]), ('data/command_like_payload', 'data', ['command_like_payload'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [4, 5, 6, 7, 8, 9], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}]), ('data/hangup', 'data', ['hangup'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [], 'reported': ['hangup']}, 'frames': []}]), ('command/line_reset', 'command', ['line_reset'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['reset']}, 'frames': []}]), ('ordered trace 0', 'command', ['enter_data', 'mode_nack', 'line_reset', 'enter_data', 'mode_ack', 'hangup', 'enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': [['ENTER_DATA', 4]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['mode_refused']}, 'frames': [['ENTER_DATA', 4]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 4]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 4], ['ENTER_DATA', 4]]}, {'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 4], ['ENTER_DATA', 4]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [], 'reported': ['mode_refused', 'reset', 'hangup']}, 'frames': [['ENTER_DATA', 4], ['ENTER_DATA', 4]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [], 'reported': ['mode_refused', 'reset', 'hangup']}, 'frames': [['ENTER_DATA', 4], ['ENTER_DATA', 4], ['ENTER_DATA', 4]]}]), ('ordered trace 3', 'data', ['escape_guard_start', 'guard_satisfied', 'line_reset', 'enter_data', 'mode_nack', 'line_reset', 'enter_data'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['reset']}, 'frames': []}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['reset']}, 'frames': [['ENTER_DATA', 4]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['reset', 'mode_refused']}, 'frames': [['ENTER_DATA', 4]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['reset', 'mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 4]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['reset', 'mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 4], ['ENTER_DATA', 4]]}]), ('empty input', 'command', [], []), ('unknown event', 'command', ['unsupported'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': [['reject', [4, 5, 6, 7, 8, 9]]]}])], 5: [('command/enter_data', 'command', ['enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': [['ENTER_DATA', 5]]}]), ('switching/mode_ack', 'switching', ['mode_ack'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}]), ('switching/mode_nack', 'switching', ['mode_nack'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['mode_refused']}, 'frames': []}]), ('data/escape_guard_start', 'data', ['escape_guard_start'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}]), ('guarding/guard_satisfied', 'guarding', ['guard_satisfied'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}]), ('guarding/guard_broken', 'guarding', ['guard_broken'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [4], 'candidate': [], 'delivered': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}]), ('command/payload', 'command', ['payload'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['not_data_mode']}, 'frames': []}]), ('data/command_like_payload', 'data', ['command_like_payload'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [5, 6, 7, 8, 9, 10, 11], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}]), ('data/hangup', 'data', ['hangup'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [], 'reported': ['hangup']}, 'frames': []}]), ('command/line_reset', 'command', ['line_reset'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset']}, 'frames': []}]), ('ordered trace 0', 'command', ['enter_data', 'mode_nack', 'line_reset', 'enter_data', 'mode_ack', 'hangup', 'enter_data', 'mode_nack'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': [['ENTER_DATA', 5]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['mode_refused']}, 'frames': [['ENTER_DATA', 5]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 5]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5]]}, {'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [], 'reported': ['mode_refused', 'reset', 'hangup']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [], 'reported': ['mode_refused', 'reset', 'hangup']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5], ['ENTER_DATA', 5]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [], 'reported': ['mode_refused', 'reset', 'hangup', 'mode_refused']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5], ['ENTER_DATA', 5]]}]), ('ordered trace 3', 'data', ['escape_guard_start', 'guard_satisfied', 'line_reset', 'enter_data', 'mode_nack', 'line_reset', 'enter_data', 'mode_ack'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset']}, 'frames': []}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset']}, 'frames': [['ENTER_DATA', 5]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset', 'mode_refused']}, 'frames': [['ENTER_DATA', 5]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset', 'mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 5]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset', 'mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5]]}, {'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset', 'mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5]]}]), ('empty input', 'command', [], []), ('unknown event', 'command', ['unsupported'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': [['reject', [5, 6, 7, 8, 9, 10, 11]]]}])]}
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 = {'parser': 'data' if phase in ('data','guarding') else 'command', 'partial_command': [seed-1], 'candidate': payload[:], 'delivered': [], 'queue': payload[:], 'reported': []}
    frames = []
    observed = []
    table = {('command', 'enter_data'): ('switching', 'send_mode_request'), ('switching', 'mode_ack'): ('data', 'enable_payload'), ('switching', 'mode_nack'): ('command', 'report_refused'), ('data', 'escape_guard_start'): ('guarding', 'deliver_escape'), ('guarding', 'guard_satisfied'): ('command', 'consume_escape'), ('guarding', 'guard_broken'): ('data', 'deliver_candidate_and_data'), ('command', 'payload'): ('command', 'reject_data'), ('data', 'command_like_payload'): ('data', 'deliver_verbatim'), ('data', 'hangup'): ('command', 'flush_close_report'), ('command', 'line_reset'): ('command', 'reset_parser_report')}
    for event in events:
        phase, action = table.get((phase, event), (phase, "reject"))
        if action == 'send_mode_request':
            frames.append(['ENTER_DATA',seed])
        elif action == 'enable_payload':
            r['parser']='data'
        elif action == 'report_refused':
            r['reported'].append('mode_refused')
        elif action == 'hold_escape_candidate':
            r['candidate']=payload[:]
        elif action == 'consume_escape':
            r['candidate']=[]; r['parser']='command'
        elif action == 'deliver_candidate_and_data':
            r['delivered'].extend(r['candidate']+payload); r['candidate']=[]
        elif action == 'reject_data':
            r['reported'].append('not_data_mode')
        elif action == 'deliver_verbatim':
            r['delivered'].extend(payload)
        elif action == 'flush_close_report':
            r['queue']=[]; r['reported'].append('hangup'); r['parser']='command'
        elif action == 'reset_parser_report':
            r['partial_command']=[]; r['reported'].append('reset')
        elif action == 'send_payload':
            frames.append(['DATA',payload])
        elif action == 'flush_input':
            r['partial_command']=[]
        elif action == 'keep_commands':
            r['parser']='command'
        elif action == 'keep_command_parser':
            r['parser']='command'
        elif action == 'drop_response':
            r['reported']=[]
        elif action == 'parse_command':
            r['partial_command'].extend(payload)
        elif action == 'deliver_escape':
            r['delivered'].extend(r['candidate'])
        elif action == 'drop_candidate':
            r['candidate']=[]
        elif action == 'deliver':
            r['delivered'].extend(payload)
        elif action == 'queue_forever':
            r['queue'].extend(payload)
        elif action == 'execute_command':
            frames.append(['EXECUTE',payload])
        elif action == 'strip_prefix':
            r['delivered'].extend(payload[1:])
        elif action == 'keep_payload_queue':
            r['reported'].append('hangup')
        elif action == 'retain_partial_command':
            r['reported'].append('reset')
        elif action == 'continue':
            r['queue'].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: [('command/enter_data', 'command', ['enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': [['ENTER_DATA', 1]]}]), ('switching/mode_ack', 'switching', ['mode_ack'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}]), ('switching/mode_nack', 'switching', ['mode_nack'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['mode_refused']}, 'frames': []}]), ('data/escape_guard_start', 'data', ['escape_guard_start'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}]), ('guarding/guard_satisfied', 'guarding', ['guard_satisfied'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}]), ('guarding/guard_broken', 'guarding', ['guard_broken'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [0], 'candidate': [], 'delivered': [1, 2, 3, 1, 2, 3], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}]), ('command/payload', 'command', ['payload'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['not_data_mode']}, 'frames': []}]), ('data/command_like_payload', 'data', ['command_like_payload'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [1, 2, 3], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}]), ('data/hangup', 'data', ['hangup'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [], 'reported': ['hangup']}, 'frames': []}]), ('command/line_reset', 'command', ['line_reset'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['reset']}, 'frames': []}]), ('ordered trace 0', 'command', ['enter_data', 'mode_nack', 'line_reset', 'enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': [['ENTER_DATA', 1]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['mode_refused']}, 'frames': [['ENTER_DATA', 1]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 1]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 1], ['ENTER_DATA', 1]]}]), ('ordered trace 3', 'data', ['escape_guard_start', 'guard_satisfied', 'line_reset', 'enter_data'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['reset']}, 'frames': []}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [1, 2, 3], 'reported': ['reset']}, 'frames': [['ENTER_DATA', 1]]}]), ('empty input', 'command', [], []), ('unknown event', 'command', ['unsupported'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [0], 'candidate': [1, 2, 3], 'delivered': [], 'queue': [1, 2, 3], 'reported': []}, 'frames': [['reject', [1, 2, 3]]]}])], 2: [('command/enter_data', 'command', ['enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': [['ENTER_DATA', 2]]}]), ('switching/mode_ack', 'switching', ['mode_ack'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}]), ('switching/mode_nack', 'switching', ['mode_nack'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['mode_refused']}, 'frames': []}]), ('data/escape_guard_start', 'data', ['escape_guard_start'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}]), ('guarding/guard_satisfied', 'guarding', ['guard_satisfied'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}]), ('guarding/guard_broken', 'guarding', ['guard_broken'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [1], 'candidate': [], 'delivered': [2, 3, 4, 5, 2, 3, 4, 5], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}]), ('command/payload', 'command', ['payload'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['not_data_mode']}, 'frames': []}]), ('data/command_like_payload', 'data', ['command_like_payload'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [2, 3, 4, 5], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}]), ('data/hangup', 'data', ['hangup'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [], 'reported': ['hangup']}, 'frames': []}]), ('command/line_reset', 'command', ['line_reset'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['reset']}, 'frames': []}]), ('ordered trace 0', 'command', ['enter_data', 'mode_nack', 'line_reset', 'enter_data', 'mode_ack'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': [['ENTER_DATA', 2]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['mode_refused']}, 'frames': [['ENTER_DATA', 2]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 2]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 2], ['ENTER_DATA', 2]]}, {'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 2], ['ENTER_DATA', 2]]}]), ('ordered trace 3', 'data', ['escape_guard_start', 'guard_satisfied', 'line_reset', 'enter_data', 'mode_nack'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['reset']}, 'frames': []}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['reset']}, 'frames': [['ENTER_DATA', 2]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': ['reset', 'mode_refused']}, 'frames': [['ENTER_DATA', 2]]}]), ('empty input', 'command', [], []), ('unknown event', 'command', ['unsupported'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [1], 'candidate': [2, 3, 4, 5], 'delivered': [], 'queue': [2, 3, 4, 5], 'reported': []}, 'frames': [['reject', [2, 3, 4, 5]]]}])], 3: [('command/enter_data', 'command', ['enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': [['ENTER_DATA', 3]]}]), ('switching/mode_ack', 'switching', ['mode_ack'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}]), ('switching/mode_nack', 'switching', ['mode_nack'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['mode_refused']}, 'frames': []}]), ('data/escape_guard_start', 'data', ['escape_guard_start'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}]), ('guarding/guard_satisfied', 'guarding', ['guard_satisfied'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}]), ('guarding/guard_broken', 'guarding', ['guard_broken'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [2], 'candidate': [], 'delivered': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}]), ('command/payload', 'command', ['payload'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['not_data_mode']}, 'frames': []}]), ('data/command_like_payload', 'data', ['command_like_payload'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [3, 4, 5, 6, 7], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}]), ('data/hangup', 'data', ['hangup'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [], 'reported': ['hangup']}, 'frames': []}]), ('command/line_reset', 'command', ['line_reset'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['reset']}, 'frames': []}]), ('ordered trace 0', 'command', ['enter_data', 'mode_nack', 'line_reset', 'enter_data', 'mode_ack', 'hangup'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': [['ENTER_DATA', 3]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['mode_refused']}, 'frames': [['ENTER_DATA', 3]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 3]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 3], ['ENTER_DATA', 3]]}, {'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 3], ['ENTER_DATA', 3]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [], 'reported': ['mode_refused', 'reset', 'hangup']}, 'frames': [['ENTER_DATA', 3], ['ENTER_DATA', 3]]}]), ('ordered trace 3', 'data', ['escape_guard_start', 'guard_satisfied', 'line_reset', 'enter_data', 'mode_nack', 'line_reset'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['reset']}, 'frames': []}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['reset']}, 'frames': [['ENTER_DATA', 3]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['reset', 'mode_refused']}, 'frames': [['ENTER_DATA', 3]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': ['reset', 'mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 3]]}]), ('empty input', 'command', [], []), ('unknown event', 'command', ['unsupported'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [2], 'candidate': [3, 4, 5, 6, 7], 'delivered': [], 'queue': [3, 4, 5, 6, 7], 'reported': []}, 'frames': [['reject', [3, 4, 5, 6, 7]]]}])], 4: [('command/enter_data', 'command', ['enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': [['ENTER_DATA', 4]]}]), ('switching/mode_ack', 'switching', ['mode_ack'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}]), ('switching/mode_nack', 'switching', ['mode_nack'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['mode_refused']}, 'frames': []}]), ('data/escape_guard_start', 'data', ['escape_guard_start'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}]), ('guarding/guard_satisfied', 'guarding', ['guard_satisfied'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}]), ('guarding/guard_broken', 'guarding', ['guard_broken'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [3], 'candidate': [], 'delivered': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}]), ('command/payload', 'command', ['payload'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['not_data_mode']}, 'frames': []}]), ('data/command_like_payload', 'data', ['command_like_payload'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [4, 5, 6, 7, 8, 9], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}]), ('data/hangup', 'data', ['hangup'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [], 'reported': ['hangup']}, 'frames': []}]), ('command/line_reset', 'command', ['line_reset'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['reset']}, 'frames': []}]), ('ordered trace 0', 'command', ['enter_data', 'mode_nack', 'line_reset', 'enter_data', 'mode_ack', 'hangup', 'enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': [['ENTER_DATA', 4]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['mode_refused']}, 'frames': [['ENTER_DATA', 4]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 4]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 4], ['ENTER_DATA', 4]]}, {'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 4], ['ENTER_DATA', 4]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [], 'reported': ['mode_refused', 'reset', 'hangup']}, 'frames': [['ENTER_DATA', 4], ['ENTER_DATA', 4]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [], 'reported': ['mode_refused', 'reset', 'hangup']}, 'frames': [['ENTER_DATA', 4], ['ENTER_DATA', 4], ['ENTER_DATA', 4]]}]), ('ordered trace 3', 'data', ['escape_guard_start', 'guard_satisfied', 'line_reset', 'enter_data', 'mode_nack', 'line_reset', 'enter_data'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['reset']}, 'frames': []}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['reset']}, 'frames': [['ENTER_DATA', 4]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['reset', 'mode_refused']}, 'frames': [['ENTER_DATA', 4]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['reset', 'mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 4]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': ['reset', 'mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 4], ['ENTER_DATA', 4]]}]), ('empty input', 'command', [], []), ('unknown event', 'command', ['unsupported'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [3], 'candidate': [4, 5, 6, 7, 8, 9], 'delivered': [], 'queue': [4, 5, 6, 7, 8, 9], 'reported': []}, 'frames': [['reject', [4, 5, 6, 7, 8, 9]]]}])], 5: [('command/enter_data', 'command', ['enter_data'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': [['ENTER_DATA', 5]]}]), ('switching/mode_ack', 'switching', ['mode_ack'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}]), ('switching/mode_nack', 'switching', ['mode_nack'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['mode_refused']}, 'frames': []}]), ('data/escape_guard_start', 'data', ['escape_guard_start'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}]), ('guarding/guard_satisfied', 'guarding', ['guard_satisfied'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}]), ('guarding/guard_broken', 'guarding', ['guard_broken'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [4], 'candidate': [], 'delivered': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}]), ('command/payload', 'command', ['payload'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['not_data_mode']}, 'frames': []}]), ('data/command_like_payload', 'data', ['command_like_payload'], [{'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [5, 6, 7, 8, 9, 10, 11], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}]), ('data/hangup', 'data', ['hangup'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [], 'reported': ['hangup']}, 'frames': []}]), ('command/line_reset', 'command', ['line_reset'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset']}, 'frames': []}]), ('ordered trace 0', 'command', ['enter_data', 'mode_nack', 'line_reset', 'enter_data', 'mode_ack', 'hangup', 'enter_data', 'mode_nack'], [{'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': [['ENTER_DATA', 5]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['mode_refused']}, 'frames': [['ENTER_DATA', 5]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 5]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5]]}, {'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [], 'reported': ['mode_refused', 'reset', 'hangup']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [], 'reported': ['mode_refused', 'reset', 'hangup']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5], ['ENTER_DATA', 5]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [], 'reported': ['mode_refused', 'reset', 'hangup', 'mode_refused']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5], ['ENTER_DATA', 5]]}]), ('ordered trace 3', 'data', ['escape_guard_start', 'guard_satisfied', 'line_reset', 'enter_data', 'mode_nack', 'line_reset', 'enter_data', 'mode_ack'], [{'phase': 'guarding', 'registers': {'parser': 'data', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': []}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset']}, 'frames': []}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset']}, 'frames': [['ENTER_DATA', 5]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset', 'mode_refused']}, 'frames': [['ENTER_DATA', 5]]}, {'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset', 'mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 5]]}, {'phase': 'switching', 'registers': {'parser': 'command', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset', 'mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5]]}, {'phase': 'data', 'registers': {'parser': 'data', 'partial_command': [], 'candidate': [], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': ['reset', 'mode_refused', 'reset']}, 'frames': [['ENTER_DATA', 5], ['ENTER_DATA', 5]]}]), ('empty input', 'command', [], []), ('unknown event', 'command', ['unsupported'], [{'phase': 'command', 'registers': {'parser': 'command', 'partial_command': [4], 'candidate': [5, 6, 7, 8, 9, 10, 11], 'delivered': [], 'queue': [5, 6, 7, 8, 9, 10, 11], 'reported': []}, 'frames': [['reject', [5, 6, 7, 8, 9, 10, 11]]]}])]}
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 data, event escape_guard_start produces command/parse_command instead of guarding/hold_escape_candidate.

For the stipulated Serial line command and data mode 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