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 = {'address': seed if phase in ('bound','renewing') else None, 'expiry': seed+2 if phase in ('bound','renewing') else None, 'selected': seed+1 if phase!='unassigned' else None, 'offers': [seed+1,seed+2], 'announced': phase in ('bound','renewing'), 'released': False}
    frames = []
    observed = []
    table = {('unassigned', 'solicit'): ('bound', 'use_default'), ('discovering', 'offer'): ('offered', 'record_offer'), ('offered', 'select'): ('requesting', 'request_selected'), ('requesting', 'ack'): ('bound', 'install_lease'), ('requesting', 'nack'): ('unassigned', 'discard_offer'), ('bound', 'renew_due'): ('renewing', 'request_renewal'), ('renewing', 'renew_ack'): ('bound', 'replace_expiry'), ('renewing', 'expired'): ('unassigned', 'clear_address'), ('bound', 'conflict_detected'): ('unassigned', 'decline_clear'), ('bound', 'release'): ('unassigned', 'release_clear')}
    for event in events:
        phase, action = table.get((phase, event), (phase, "reject"))
        if action == 'send_discovery':
            frames.append(['DISCOVER',seed])
        elif action == 'record_offer':
            r['selected']=seed+1
        elif action == 'request_selected':
            frames.append(['REQUEST_ADDRESS',r['selected']])
        elif action == 'install_lease':
            r['address']=r['selected']; r['expiry']=seed+len(payload)+2
        elif action == 'discard_offer':
            r['address']=None; r['selected']=None
        elif action == 'request_renewal':
            frames.append(['RENEW_ADDRESS',r['address']])
        elif action == 'replace_expiry':
            r['expiry']=seed+len(payload)+2
        elif action == 'clear_address':
            r['address']=None; r['announced']=False
        elif action == 'decline_clear':
            frames.append(['DECLINE',r['address']]); r['address']=None; r['announced']=False
        elif action == 'release_clear':
            frames.append(['RELEASE',r['address']]); r['address']=None; r['announced']=False; r['released']=True
        elif action == 'use_default':
            r['address']=0
        elif action == 'send_payload':
            frames.append(['DATA',r['address'],payload])
        elif action == 'use_address':
            frames.append(['DATA',r['address'],payload])
        elif action == 'announce_address':
            r['announced']=True; frames.append(['ANNOUNCE',r['address']])
        elif action == 'request_all_offers':
            frames.extend([['REQUEST_ADDRESS',a] for a in r['offers']])
        elif action == 'install_offer_without_lifetime':
            r['address']=r['selected']; r['expiry']=None
        elif action == 'stop_using_address':
            r['address']=None
        elif action == 'clear_without_decline':
            r['address']=None; r['announced']=False
        elif action == 'clear_without_release':
            r['address']=None; r['announced']=False
        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: [('unassigned/solicit', 'unassigned', ['solicit'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1]]}]), ('discovering/offer', 'discovering', ['offer'], [{'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': []}]), ('offered/select', 'offered', ['select'], [{'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['REQUEST_ADDRESS', 2]]}]), ('requesting/ack', 'requesting', ['ack'], [{'phase': 'bound', 'registers': {'address': 2, 'expiry': 6, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': []}]), ('requesting/nack', 'requesting', ['nack'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': []}]), ('bound/renew_due', 'bound', ['renew_due'], [{'phase': 'renewing', 'registers': {'address': 1, 'expiry': 3, 'selected': 2, 'offers': [2, 3], 'announced': True, 'released': False}, 'frames': [['RENEW_ADDRESS', 1]]}]), ('renewing/renew_ack', 'renewing', ['renew_ack'], [{'phase': 'bound', 'registers': {'address': 1, 'expiry': 6, 'selected': 2, 'offers': [2, 3], 'announced': True, 'released': False}, 'frames': []}]), ('renewing/expired', 'renewing', ['expired'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 3, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': []}]), ('bound/conflict_detected', 'bound', ['conflict_detected'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 3, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DECLINE', 1]]}]), ('bound/release', 'bound', ['release'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 3, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': True}, 'frames': [['RELEASE', 1]]}]), ('ordered trace 0', 'unassigned', ['solicit', 'offer', 'select', 'nack'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1], ['REQUEST_ADDRESS', 2]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1], ['REQUEST_ADDRESS', 2]]}]), ('ordered trace 3', 'requesting', ['nack', 'solicit', 'offer', 'select'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': []}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1], ['REQUEST_ADDRESS', 2]]}]), ('empty input', 'unassigned', [], []), ('unknown event', 'unassigned', ['unsupported'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['reject', [1, 2, 3]]]}])], 2: [('unassigned/solicit', 'unassigned', ['solicit'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2]]}]), ('discovering/offer', 'discovering', ['offer'], [{'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': []}]), ('offered/select', 'offered', ['select'], [{'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['REQUEST_ADDRESS', 3]]}]), ('requesting/ack', 'requesting', ['ack'], [{'phase': 'bound', 'registers': {'address': 3, 'expiry': 8, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': []}]), ('requesting/nack', 'requesting', ['nack'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': []}]), ('bound/renew_due', 'bound', ['renew_due'], [{'phase': 'renewing', 'registers': {'address': 2, 'expiry': 4, 'selected': 3, 'offers': [3, 4], 'announced': True, 'released': False}, 'frames': [['RENEW_ADDRESS', 2]]}]), ('renewing/renew_ack', 'renewing', ['renew_ack'], [{'phase': 'bound', 'registers': {'address': 2, 'expiry': 8, 'selected': 3, 'offers': [3, 4], 'announced': True, 'released': False}, 'frames': []}]), ('renewing/expired', 'renewing', ['expired'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 4, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': []}]), ('bound/conflict_detected', 'bound', ['conflict_detected'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 4, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DECLINE', 2]]}]), ('bound/release', 'bound', ['release'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 4, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': True}, 'frames': [['RELEASE', 2]]}]), ('ordered trace 0', 'unassigned', ['solicit', 'offer', 'select', 'nack', 'solicit'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2], ['REQUEST_ADDRESS', 3]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2], ['REQUEST_ADDRESS', 3]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2], ['REQUEST_ADDRESS', 3], ['DISCOVER', 2]]}]), ('ordered trace 3', 'requesting', ['nack', 'solicit', 'offer', 'select', 'nack'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': []}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2], ['REQUEST_ADDRESS', 3]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2], ['REQUEST_ADDRESS', 3]]}]), ('empty input', 'unassigned', [], []), ('unknown event', 'unassigned', ['unsupported'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['reject', [2, 3, 4, 5]]]}])], 3: [('unassigned/solicit', 'unassigned', ['solicit'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3]]}]), ('discovering/offer', 'discovering', ['offer'], [{'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': []}]), ('offered/select', 'offered', ['select'], [{'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['REQUEST_ADDRESS', 4]]}]), ('requesting/ack', 'requesting', ['ack'], [{'phase': 'bound', 'registers': {'address': 4, 'expiry': 10, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': []}]), ('requesting/nack', 'requesting', ['nack'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': []}]), ('bound/renew_due', 'bound', ['renew_due'], [{'phase': 'renewing', 'registers': {'address': 3, 'expiry': 5, 'selected': 4, 'offers': [4, 5], 'announced': True, 'released': False}, 'frames': [['RENEW_ADDRESS', 3]]}]), ('renewing/renew_ack', 'renewing', ['renew_ack'], [{'phase': 'bound', 'registers': {'address': 3, 'expiry': 10, 'selected': 4, 'offers': [4, 5], 'announced': True, 'released': False}, 'frames': []}]), ('renewing/expired', 'renewing', ['expired'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 5, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': []}]), ('bound/conflict_detected', 'bound', ['conflict_detected'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 5, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DECLINE', 3]]}]), ('bound/release', 'bound', ['release'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 5, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': True}, 'frames': [['RELEASE', 3]]}]), ('ordered trace 0', 'unassigned', ['solicit', 'offer', 'select', 'nack', 'solicit', 'offer'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4], ['DISCOVER', 3]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4], ['DISCOVER', 3]]}]), ('ordered trace 3', 'requesting', ['nack', 'solicit', 'offer', 'select', 'nack', 'solicit'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': []}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4], ['DISCOVER', 3]]}]), ('empty input', 'unassigned', [], []), ('unknown event', 'unassigned', ['unsupported'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['reject', [3, 4, 5, 6, 7]]]}])], 4: [('unassigned/solicit', 'unassigned', ['solicit'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4]]}]), ('discovering/offer', 'discovering', ['offer'], [{'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': []}]), ('offered/select', 'offered', ['select'], [{'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['REQUEST_ADDRESS', 5]]}]), ('requesting/ack', 'requesting', ['ack'], [{'phase': 'bound', 'registers': {'address': 5, 'expiry': 12, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': []}]), ('requesting/nack', 'requesting', ['nack'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': []}]), ('bound/renew_due', 'bound', ['renew_due'], [{'phase': 'renewing', 'registers': {'address': 4, 'expiry': 6, 'selected': 5, 'offers': [5, 6], 'announced': True, 'released': False}, 'frames': [['RENEW_ADDRESS', 4]]}]), ('renewing/renew_ack', 'renewing', ['renew_ack'], [{'phase': 'bound', 'registers': {'address': 4, 'expiry': 12, 'selected': 5, 'offers': [5, 6], 'announced': True, 'released': False}, 'frames': []}]), ('renewing/expired', 'renewing', ['expired'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 6, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': []}]), ('bound/conflict_detected', 'bound', ['conflict_detected'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 6, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DECLINE', 4]]}]), ('bound/release', 'bound', ['release'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 6, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': True}, 'frames': [['RELEASE', 4]]}]), ('ordered trace 0', 'unassigned', ['solicit', 'offer', 'select', 'nack', 'solicit', 'offer', 'select'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5], ['DISCOVER', 4]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5], ['DISCOVER', 4]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5], ['DISCOVER', 4], ['REQUEST_ADDRESS', 5]]}]), ('ordered trace 3', 'requesting', ['nack', 'solicit', 'offer', 'select', 'nack', 'solicit', 'offer'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': []}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5], ['DISCOVER', 4]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5], ['DISCOVER', 4]]}]), ('empty input', 'unassigned', [], []), ('unknown event', 'unassigned', ['unsupported'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['reject', [4, 5, 6, 7, 8, 9]]]}])], 5: [('unassigned/solicit', 'unassigned', ['solicit'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5]]}]), ('discovering/offer', 'discovering', ['offer'], [{'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': []}]), ('offered/select', 'offered', ['select'], [{'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['REQUEST_ADDRESS', 6]]}]), ('requesting/ack', 'requesting', ['ack'], [{'phase': 'bound', 'registers': {'address': 6, 'expiry': 14, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': []}]), ('requesting/nack', 'requesting', ['nack'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': []}]), ('bound/renew_due', 'bound', ['renew_due'], [{'phase': 'renewing', 'registers': {'address': 5, 'expiry': 7, 'selected': 6, 'offers': [6, 7], 'announced': True, 'released': False}, 'frames': [['RENEW_ADDRESS', 5]]}]), ('renewing/renew_ack', 'renewing', ['renew_ack'], [{'phase': 'bound', 'registers': {'address': 5, 'expiry': 14, 'selected': 6, 'offers': [6, 7], 'announced': True, 'released': False}, 'frames': []}]), ('renewing/expired', 'renewing', ['expired'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 7, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': []}]), ('bound/conflict_detected', 'bound', ['conflict_detected'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 7, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DECLINE', 5]]}]), ('bound/release', 'bound', ['release'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 7, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': True}, 'frames': [['RELEASE', 5]]}]), ('ordered trace 0', 'unassigned', ['solicit', 'offer', 'select', 'nack', 'solicit', 'offer', 'select', 'nack'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}]), ('ordered trace 3', 'requesting', ['nack', 'solicit', 'offer', 'select', 'nack', 'solicit', 'offer', 'select'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': []}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}]), ('empty input', 'unassigned', [], []), ('unknown event', 'unassigned', ['unsupported'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, '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)

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 = {'address': seed if phase in ('bound','renewing') else None, 'expiry': seed+2 if phase in ('bound','renewing') else None, 'selected': seed+1 if phase!='unassigned' else None, 'offers': [seed+1,seed+2], 'announced': phase in ('bound','renewing'), 'released': False}
    frames = []
    observed = []
    table = {('unassigned', 'solicit'): ('unassigned', 'send_payload'), ('discovering', 'offer'): ('offered', 'record_offer'), ('offered', 'select'): ('requesting', 'request_selected'), ('requesting', 'ack'): ('bound', 'install_lease'), ('requesting', 'nack'): ('unassigned', 'discard_offer'), ('bound', 'renew_due'): ('renewing', 'request_renewal'), ('renewing', 'renew_ack'): ('bound', 'replace_expiry'), ('renewing', 'expired'): ('unassigned', 'clear_address'), ('bound', 'conflict_detected'): ('unassigned', 'decline_clear'), ('bound', 'release'): ('unassigned', 'release_clear')}
    for event in events:
        phase, action = table.get((phase, event), (phase, "reject"))
        if action == 'send_discovery':
            frames.append(['DISCOVER',seed])
        elif action == 'record_offer':
            r['selected']=seed+1
        elif action == 'request_selected':
            frames.append(['REQUEST_ADDRESS',r['selected']])
        elif action == 'install_lease':
            r['address']=r['selected']; r['expiry']=seed+len(payload)+2
        elif action == 'discard_offer':
            r['address']=None; r['selected']=None
        elif action == 'request_renewal':
            frames.append(['RENEW_ADDRESS',r['address']])
        elif action == 'replace_expiry':
            r['expiry']=seed+len(payload)+2
        elif action == 'clear_address':
            r['address']=None; r['announced']=False
        elif action == 'decline_clear':
            frames.append(['DECLINE',r['address']]); r['address']=None; r['announced']=False
        elif action == 'release_clear':
            frames.append(['RELEASE',r['address']]); r['address']=None; r['announced']=False; r['released']=True
        elif action == 'use_default':
            r['address']=0
        elif action == 'send_payload':
            frames.append(['DATA',r['address'],payload])
        elif action == 'use_address':
            frames.append(['DATA',r['address'],payload])
        elif action == 'announce_address':
            r['announced']=True; frames.append(['ANNOUNCE',r['address']])
        elif action == 'request_all_offers':
            frames.extend([['REQUEST_ADDRESS',a] for a in r['offers']])
        elif action == 'install_offer_without_lifetime':
            r['address']=r['selected']; r['expiry']=None
        elif action == 'stop_using_address':
            r['address']=None
        elif action == 'clear_without_decline':
            r['address']=None; r['announced']=False
        elif action == 'clear_without_release':
            r['address']=None; r['announced']=False
        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: [('unassigned/solicit', 'unassigned', ['solicit'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1]]}]), ('discovering/offer', 'discovering', ['offer'], [{'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': []}]), ('offered/select', 'offered', ['select'], [{'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['REQUEST_ADDRESS', 2]]}]), ('requesting/ack', 'requesting', ['ack'], [{'phase': 'bound', 'registers': {'address': 2, 'expiry': 6, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': []}]), ('requesting/nack', 'requesting', ['nack'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': []}]), ('bound/renew_due', 'bound', ['renew_due'], [{'phase': 'renewing', 'registers': {'address': 1, 'expiry': 3, 'selected': 2, 'offers': [2, 3], 'announced': True, 'released': False}, 'frames': [['RENEW_ADDRESS', 1]]}]), ('renewing/renew_ack', 'renewing', ['renew_ack'], [{'phase': 'bound', 'registers': {'address': 1, 'expiry': 6, 'selected': 2, 'offers': [2, 3], 'announced': True, 'released': False}, 'frames': []}]), ('renewing/expired', 'renewing', ['expired'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 3, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': []}]), ('bound/conflict_detected', 'bound', ['conflict_detected'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 3, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DECLINE', 1]]}]), ('bound/release', 'bound', ['release'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 3, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': True}, 'frames': [['RELEASE', 1]]}]), ('ordered trace 0', 'unassigned', ['solicit', 'offer', 'select', 'nack'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1], ['REQUEST_ADDRESS', 2]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1], ['REQUEST_ADDRESS', 2]]}]), ('ordered trace 3', 'requesting', ['nack', 'solicit', 'offer', 'select'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': []}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 2, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 1], ['REQUEST_ADDRESS', 2]]}]), ('empty input', 'unassigned', [], []), ('unknown event', 'unassigned', ['unsupported'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [2, 3], 'announced': False, 'released': False}, 'frames': [['reject', [1, 2, 3]]]}])], 2: [('unassigned/solicit', 'unassigned', ['solicit'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2]]}]), ('discovering/offer', 'discovering', ['offer'], [{'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': []}]), ('offered/select', 'offered', ['select'], [{'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['REQUEST_ADDRESS', 3]]}]), ('requesting/ack', 'requesting', ['ack'], [{'phase': 'bound', 'registers': {'address': 3, 'expiry': 8, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': []}]), ('requesting/nack', 'requesting', ['nack'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': []}]), ('bound/renew_due', 'bound', ['renew_due'], [{'phase': 'renewing', 'registers': {'address': 2, 'expiry': 4, 'selected': 3, 'offers': [3, 4], 'announced': True, 'released': False}, 'frames': [['RENEW_ADDRESS', 2]]}]), ('renewing/renew_ack', 'renewing', ['renew_ack'], [{'phase': 'bound', 'registers': {'address': 2, 'expiry': 8, 'selected': 3, 'offers': [3, 4], 'announced': True, 'released': False}, 'frames': []}]), ('renewing/expired', 'renewing', ['expired'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 4, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': []}]), ('bound/conflict_detected', 'bound', ['conflict_detected'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 4, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DECLINE', 2]]}]), ('bound/release', 'bound', ['release'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 4, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': True}, 'frames': [['RELEASE', 2]]}]), ('ordered trace 0', 'unassigned', ['solicit', 'offer', 'select', 'nack', 'solicit'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2], ['REQUEST_ADDRESS', 3]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2], ['REQUEST_ADDRESS', 3]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2], ['REQUEST_ADDRESS', 3], ['DISCOVER', 2]]}]), ('ordered trace 3', 'requesting', ['nack', 'solicit', 'offer', 'select', 'nack'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': []}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 3, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2], ['REQUEST_ADDRESS', 3]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 2], ['REQUEST_ADDRESS', 3]]}]), ('empty input', 'unassigned', [], []), ('unknown event', 'unassigned', ['unsupported'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [3, 4], 'announced': False, 'released': False}, 'frames': [['reject', [2, 3, 4, 5]]]}])], 3: [('unassigned/solicit', 'unassigned', ['solicit'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3]]}]), ('discovering/offer', 'discovering', ['offer'], [{'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': []}]), ('offered/select', 'offered', ['select'], [{'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['REQUEST_ADDRESS', 4]]}]), ('requesting/ack', 'requesting', ['ack'], [{'phase': 'bound', 'registers': {'address': 4, 'expiry': 10, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': []}]), ('requesting/nack', 'requesting', ['nack'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': []}]), ('bound/renew_due', 'bound', ['renew_due'], [{'phase': 'renewing', 'registers': {'address': 3, 'expiry': 5, 'selected': 4, 'offers': [4, 5], 'announced': True, 'released': False}, 'frames': [['RENEW_ADDRESS', 3]]}]), ('renewing/renew_ack', 'renewing', ['renew_ack'], [{'phase': 'bound', 'registers': {'address': 3, 'expiry': 10, 'selected': 4, 'offers': [4, 5], 'announced': True, 'released': False}, 'frames': []}]), ('renewing/expired', 'renewing', ['expired'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 5, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': []}]), ('bound/conflict_detected', 'bound', ['conflict_detected'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 5, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DECLINE', 3]]}]), ('bound/release', 'bound', ['release'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 5, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': True}, 'frames': [['RELEASE', 3]]}]), ('ordered trace 0', 'unassigned', ['solicit', 'offer', 'select', 'nack', 'solicit', 'offer'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4], ['DISCOVER', 3]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4], ['DISCOVER', 3]]}]), ('ordered trace 3', 'requesting', ['nack', 'solicit', 'offer', 'select', 'nack', 'solicit'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': []}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 4, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 3], ['REQUEST_ADDRESS', 4], ['DISCOVER', 3]]}]), ('empty input', 'unassigned', [], []), ('unknown event', 'unassigned', ['unsupported'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [4, 5], 'announced': False, 'released': False}, 'frames': [['reject', [3, 4, 5, 6, 7]]]}])], 4: [('unassigned/solicit', 'unassigned', ['solicit'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4]]}]), ('discovering/offer', 'discovering', ['offer'], [{'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': []}]), ('offered/select', 'offered', ['select'], [{'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['REQUEST_ADDRESS', 5]]}]), ('requesting/ack', 'requesting', ['ack'], [{'phase': 'bound', 'registers': {'address': 5, 'expiry': 12, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': []}]), ('requesting/nack', 'requesting', ['nack'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': []}]), ('bound/renew_due', 'bound', ['renew_due'], [{'phase': 'renewing', 'registers': {'address': 4, 'expiry': 6, 'selected': 5, 'offers': [5, 6], 'announced': True, 'released': False}, 'frames': [['RENEW_ADDRESS', 4]]}]), ('renewing/renew_ack', 'renewing', ['renew_ack'], [{'phase': 'bound', 'registers': {'address': 4, 'expiry': 12, 'selected': 5, 'offers': [5, 6], 'announced': True, 'released': False}, 'frames': []}]), ('renewing/expired', 'renewing', ['expired'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 6, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': []}]), ('bound/conflict_detected', 'bound', ['conflict_detected'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 6, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DECLINE', 4]]}]), ('bound/release', 'bound', ['release'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 6, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': True}, 'frames': [['RELEASE', 4]]}]), ('ordered trace 0', 'unassigned', ['solicit', 'offer', 'select', 'nack', 'solicit', 'offer', 'select'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5], ['DISCOVER', 4]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5], ['DISCOVER', 4]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5], ['DISCOVER', 4], ['REQUEST_ADDRESS', 5]]}]), ('ordered trace 3', 'requesting', ['nack', 'solicit', 'offer', 'select', 'nack', 'solicit', 'offer'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': []}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5], ['DISCOVER', 4]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 5, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 4], ['REQUEST_ADDRESS', 5], ['DISCOVER', 4]]}]), ('empty input', 'unassigned', [], []), ('unknown event', 'unassigned', ['unsupported'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [5, 6], 'announced': False, 'released': False}, 'frames': [['reject', [4, 5, 6, 7, 8, 9]]]}])], 5: [('unassigned/solicit', 'unassigned', ['solicit'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5]]}]), ('discovering/offer', 'discovering', ['offer'], [{'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': []}]), ('offered/select', 'offered', ['select'], [{'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['REQUEST_ADDRESS', 6]]}]), ('requesting/ack', 'requesting', ['ack'], [{'phase': 'bound', 'registers': {'address': 6, 'expiry': 14, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': []}]), ('requesting/nack', 'requesting', ['nack'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': []}]), ('bound/renew_due', 'bound', ['renew_due'], [{'phase': 'renewing', 'registers': {'address': 5, 'expiry': 7, 'selected': 6, 'offers': [6, 7], 'announced': True, 'released': False}, 'frames': [['RENEW_ADDRESS', 5]]}]), ('renewing/renew_ack', 'renewing', ['renew_ack'], [{'phase': 'bound', 'registers': {'address': 5, 'expiry': 14, 'selected': 6, 'offers': [6, 7], 'announced': True, 'released': False}, 'frames': []}]), ('renewing/expired', 'renewing', ['expired'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 7, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': []}]), ('bound/conflict_detected', 'bound', ['conflict_detected'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 7, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DECLINE', 5]]}]), ('bound/release', 'bound', ['release'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': 7, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': True}, 'frames': [['RELEASE', 5]]}]), ('ordered trace 0', 'unassigned', ['solicit', 'offer', 'select', 'nack', 'solicit', 'offer', 'select', 'nack'], [{'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}]), ('ordered trace 3', 'requesting', ['nack', 'solicit', 'offer', 'select', 'nack', 'solicit', 'offer', 'select'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': []}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}, {'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}, {'phase': 'discovering', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5]]}, {'phase': 'offered', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5]]}, {'phase': 'requesting', 'registers': {'address': None, 'expiry': None, 'selected': 6, 'offers': [6, 7], 'announced': False, 'released': False}, 'frames': [['DISCOVER', 5], ['REQUEST_ADDRESS', 6], ['DISCOVER', 5], ['REQUEST_ADDRESS', 6]]}]), ('empty input', 'unassigned', [], []), ('unknown event', 'unassigned', ['unsupported'], [{'phase': 'unassigned', 'registers': {'address': None, 'expiry': None, 'selected': None, 'offers': [6, 7], 'announced': False, 'released': False}, '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 unassigned, event solicit produces bound/use_default instead of discovering/send_discovery.

For the stipulated Scoped address assignment 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