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 = {'shadow': [seed] if phase in ('copying','replaying') else [], 'live': [seed-1] if phase in ('copying','replaying','live') else [], 'deltas': payload[:], 'published': phase=='live', 'notifications': []}
    frames = []
    observed = []
    table = {('empty', 'baseline_offer'): ('copying', 'create_shadow'), ('copying', 'baseline_item'): ('copying', 'write_shadow'), ('copying', 'concurrent_delta'): ('copying', 'buffer_after_cut'), ('copying', 'baseline_end'): ('replaying', 'seal_shadow'), ('replaying', 'delta'): ('replaying', 'apply_buffered_order'), ('replaying', 'buffer_empty'): ('replaying', 'wait'), ('live', 'source_reset'): ('empty', 'invalidate_baseline'), ('live', 'old_generation_delta'): ('live', 'reject_stale'), ('copying', 'copy_cancelled'): ('empty', 'discard_shadow'), ('live', 'delta'): ('live', 'apply_notify')}
    for event in events:
        phase, action = table.get((phase, event), (phase, "reject"))
        if action == 'create_shadow':
            r['shadow']=[]
        elif action == 'write_shadow':
            r['shadow'].extend(payload)
        elif action == 'buffer_after_cut':
            r['deltas'].extend(payload)
        elif action == 'seal_shadow':
            frames.append(['BASELINE_SEALED',seed])
        elif action == 'apply_buffered_order':
            r['shadow'].extend(r['deltas']); r['deltas']=[]
        elif action == 'atomic_publish':
            r['live']=r['shadow'][:]; r['published']=True
        elif action == 'invalidate_baseline':
            r['live']=[]; r['published']=False
        elif action == 'reject_stale':
            frames.append(['STALE_DELTA',seed-1])
        elif action == 'discard_shadow':
            r['shadow']=[]
        elif action == 'apply_notify':
            r['live'].extend(payload); r['notifications'].append(payload)
        elif action == 'accept_deltas':
            r['live'].extend(payload)
        elif action == 'write_live':
            r['live'].extend(payload)
        elif action == 'replace_shadow':
            r['shadow']=payload[:]
        elif action == 'drop_delta':
            r['deltas']=[]
        elif action == 'apply_before_baseline':
            r['shadow'].extend(payload)
        elif action == 'publish_shadow':
            r['live']=r['shadow'][:]; r['published']=True
        elif action == 'discard_deltas':
            r['deltas']=[]
        elif action == 'apply_reverse':
            r['shadow'].extend(reversed(r['deltas'])); r['deltas']=[]
        elif action == 'publish_early':
            r['live']=r['shadow'][:]; r['published']=True
        elif action == 'merge_with_old':
            r['live'].extend(r['shadow']); r['published']=True
        elif action == 'apply_delta':
            r['live'].extend(payload)
        elif action == 'restart_from_delta':
            r['shadow']=payload[:]
        elif action == 'buffer_forever':
            r['deltas'].extend(payload)
        elif action == 'apply_silent':
            r['live'].extend(payload)
        elif action == 'continue':
            r['live'].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: [('empty/baseline_offer', 'empty', ['baseline_offer'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_item', 'copying', ['baseline_item'], [{'phase': 'copying', 'registers': {'shadow': [1, 1, 2, 3], 'live': [0], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/concurrent_delta', 'copying', ['concurrent_delta'], [{'phase': 'copying', 'registers': {'shadow': [1], 'live': [0], 'deltas': [1, 2, 3, 1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_end', 'copying', ['baseline_end'], [{'phase': 'replaying', 'registers': {'shadow': [1], 'live': [0], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 1]]}]), ('replaying/delta', 'replaying', ['delta'], [{'phase': 'replaying', 'registers': {'shadow': [1, 1, 2, 3], 'live': [0], 'deltas': [], 'published': False, 'notifications': []}, 'frames': []}]), ('replaying/buffer_empty', 'replaying', ['buffer_empty'], [{'phase': 'live', 'registers': {'shadow': [1], 'live': [1], 'deltas': [1, 2, 3], 'published': True, 'notifications': []}, 'frames': []}]), ('live/source_reset', 'live', ['source_reset'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}]), ('live/old_generation_delta', 'live', ['old_generation_delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [0], 'deltas': [1, 2, 3], 'published': True, 'notifications': []}, 'frames': [['STALE_DELTA', 0]]}]), ('copying/copy_cancelled', 'copying', ['copy_cancelled'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [0], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}]), ('live/delta', 'live', ['delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [0, 1, 2, 3], 'deltas': [1, 2, 3], 'published': True, 'notifications': [[1, 2, 3]]}, 'frames': []}]), ('ordered trace 0', 'empty', ['baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3, 1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3, 1, 2, 3], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 1]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3, 1, 2, 3], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 1]]}]), ('ordered trace 3', 'copying', ['copy_cancelled', 'baseline_offer', 'concurrent_delta', 'baseline_end'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [0], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [0], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [0], 'deltas': [1, 2, 3, 1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [0], 'deltas': [1, 2, 3, 1, 2, 3], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 1]]}]), ('empty input', 'empty', [], []), ('unknown event', 'empty', ['unsupported'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': [['reject', [1, 2, 3]]]}])], 2: [('empty/baseline_offer', 'empty', ['baseline_offer'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_item', 'copying', ['baseline_item'], [{'phase': 'copying', 'registers': {'shadow': [2, 2, 3, 4, 5], 'live': [1], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/concurrent_delta', 'copying', ['concurrent_delta'], [{'phase': 'copying', 'registers': {'shadow': [2], 'live': [1], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_end', 'copying', ['baseline_end'], [{'phase': 'replaying', 'registers': {'shadow': [2], 'live': [1], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 2]]}]), ('replaying/delta', 'replaying', ['delta'], [{'phase': 'replaying', 'registers': {'shadow': [2, 2, 3, 4, 5], 'live': [1], 'deltas': [], 'published': False, 'notifications': []}, 'frames': []}]), ('replaying/buffer_empty', 'replaying', ['buffer_empty'], [{'phase': 'live', 'registers': {'shadow': [2], 'live': [2], 'deltas': [2, 3, 4, 5], 'published': True, 'notifications': []}, 'frames': []}]), ('live/source_reset', 'live', ['source_reset'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}]), ('live/old_generation_delta', 'live', ['old_generation_delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [1], 'deltas': [2, 3, 4, 5], 'published': True, 'notifications': []}, 'frames': [['STALE_DELTA', 1]]}]), ('copying/copy_cancelled', 'copying', ['copy_cancelled'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [1], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}]), ('live/delta', 'live', ['delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [1, 2, 3, 4, 5], 'deltas': [2, 3, 4, 5], 'published': True, 'notifications': [[2, 3, 4, 5]]}, 'frames': []}]), ('ordered trace 0', 'empty', ['baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'old_generation_delta'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 2]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 2]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 2], ['STALE_DELTA', 1]]}]), ('ordered trace 3', 'copying', ['copy_cancelled', 'baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [1], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [1], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [1], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [1], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 2]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 2]]}]), ('empty input', 'empty', [], []), ('unknown event', 'empty', ['unsupported'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': [['reject', [2, 3, 4, 5]]]}])], 3: [('empty/baseline_offer', 'empty', ['baseline_offer'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_item', 'copying', ['baseline_item'], [{'phase': 'copying', 'registers': {'shadow': [3, 3, 4, 5, 6, 7], 'live': [2], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/concurrent_delta', 'copying', ['concurrent_delta'], [{'phase': 'copying', 'registers': {'shadow': [3], 'live': [2], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_end', 'copying', ['baseline_end'], [{'phase': 'replaying', 'registers': {'shadow': [3], 'live': [2], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 3]]}]), ('replaying/delta', 'replaying', ['delta'], [{'phase': 'replaying', 'registers': {'shadow': [3, 3, 4, 5, 6, 7], 'live': [2], 'deltas': [], 'published': False, 'notifications': []}, 'frames': []}]), ('replaying/buffer_empty', 'replaying', ['buffer_empty'], [{'phase': 'live', 'registers': {'shadow': [3], 'live': [3], 'deltas': [3, 4, 5, 6, 7], 'published': True, 'notifications': []}, 'frames': []}]), ('live/source_reset', 'live', ['source_reset'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}]), ('live/old_generation_delta', 'live', ['old_generation_delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [2], 'deltas': [3, 4, 5, 6, 7], 'published': True, 'notifications': []}, 'frames': [['STALE_DELTA', 2]]}]), ('copying/copy_cancelled', 'copying', ['copy_cancelled'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [2], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}]), ('live/delta', 'live', ['delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [2, 3, 4, 5, 6, 7], 'deltas': [3, 4, 5, 6, 7], 'published': True, 'notifications': [[3, 4, 5, 6, 7]]}, 'frames': []}]), ('ordered trace 0', 'empty', ['baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'old_generation_delta', 'delta'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 3]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 3]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 3], ['STALE_DELTA', 2]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [3, 4, 5, 6, 7], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': True, 'notifications': [[3, 4, 5, 6, 7]]}, 'frames': [['BASELINE_SEALED', 3], ['STALE_DELTA', 2]]}]), ('ordered trace 3', 'copying', ['copy_cancelled', 'baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'delta'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [2], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [2], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [2], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [2], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 3]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 3]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [3, 4, 5, 6, 7], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': True, 'notifications': [[3, 4, 5, 6, 7]]}, 'frames': [['BASELINE_SEALED', 3]]}]), ('empty input', 'empty', [], []), ('unknown event', 'empty', ['unsupported'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': [['reject', [3, 4, 5, 6, 7]]]}])], 4: [('empty/baseline_offer', 'empty', ['baseline_offer'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_item', 'copying', ['baseline_item'], [{'phase': 'copying', 'registers': {'shadow': [4, 4, 5, 6, 7, 8, 9], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/concurrent_delta', 'copying', ['concurrent_delta'], [{'phase': 'copying', 'registers': {'shadow': [4], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_end', 'copying', ['baseline_end'], [{'phase': 'replaying', 'registers': {'shadow': [4], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 4]]}]), ('replaying/delta', 'replaying', ['delta'], [{'phase': 'replaying', 'registers': {'shadow': [4, 4, 5, 6, 7, 8, 9], 'live': [3], 'deltas': [], 'published': False, 'notifications': []}, 'frames': []}]), ('replaying/buffer_empty', 'replaying', ['buffer_empty'], [{'phase': 'live', 'registers': {'shadow': [4], 'live': [4], 'deltas': [4, 5, 6, 7, 8, 9], 'published': True, 'notifications': []}, 'frames': []}]), ('live/source_reset', 'live', ['source_reset'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}]), ('live/old_generation_delta', 'live', ['old_generation_delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9], 'published': True, 'notifications': []}, 'frames': [['STALE_DELTA', 3]]}]), ('copying/copy_cancelled', 'copying', ['copy_cancelled'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}]), ('live/delta', 'live', ['delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [3, 4, 5, 6, 7, 8, 9], 'deltas': [4, 5, 6, 7, 8, 9], 'published': True, 'notifications': [[4, 5, 6, 7, 8, 9]]}, 'frames': []}]), ('ordered trace 0', 'empty', ['baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'old_generation_delta', 'delta', 'source_reset'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 4]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 4]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 4], ['STALE_DELTA', 3]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [4, 5, 6, 7, 8, 9], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': True, 'notifications': [[4, 5, 6, 7, 8, 9]]}, 'frames': [['BASELINE_SEALED', 4], ['STALE_DELTA', 3]]}, {'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': [[4, 5, 6, 7, 8, 9]]}, 'frames': [['BASELINE_SEALED', 4], ['STALE_DELTA', 3]]}]), ('ordered trace 3', 'copying', ['copy_cancelled', 'baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'delta', 'source_reset'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 4]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 4]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [4, 5, 6, 7, 8, 9], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': True, 'notifications': [[4, 5, 6, 7, 8, 9]]}, 'frames': [['BASELINE_SEALED', 4]]}, {'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': [[4, 5, 6, 7, 8, 9]]}, 'frames': [['BASELINE_SEALED', 4]]}]), ('empty input', 'empty', [], []), ('unknown event', 'empty', ['unsupported'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': [['reject', [4, 5, 6, 7, 8, 9]]]}])], 5: [('empty/baseline_offer', 'empty', ['baseline_offer'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_item', 'copying', ['baseline_item'], [{'phase': 'copying', 'registers': {'shadow': [5, 5, 6, 7, 8, 9, 10, 11], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/concurrent_delta', 'copying', ['concurrent_delta'], [{'phase': 'copying', 'registers': {'shadow': [5], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_end', 'copying', ['baseline_end'], [{'phase': 'replaying', 'registers': {'shadow': [5], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 5]]}]), ('replaying/delta', 'replaying', ['delta'], [{'phase': 'replaying', 'registers': {'shadow': [5, 5, 6, 7, 8, 9, 10, 11], 'live': [4], 'deltas': [], 'published': False, 'notifications': []}, 'frames': []}]), ('replaying/buffer_empty', 'replaying', ['buffer_empty'], [{'phase': 'live', 'registers': {'shadow': [5], 'live': [5], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': []}, 'frames': []}]), ('live/source_reset', 'live', ['source_reset'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}]), ('live/old_generation_delta', 'live', ['old_generation_delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': []}, 'frames': [['STALE_DELTA', 4]]}]), ('copying/copy_cancelled', 'copying', ['copy_cancelled'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}]), ('live/delta', 'live', ['delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [4, 5, 6, 7, 8, 9, 10, 11], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': []}]), ('ordered trace 0', 'empty', ['baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'old_generation_delta', 'delta', 'source_reset', 'baseline_offer'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 5]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 5]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 5], ['STALE_DELTA', 4]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [5, 6, 7, 8, 9, 10, 11], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': [['BASELINE_SEALED', 5], ['STALE_DELTA', 4]]}, {'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': [['BASELINE_SEALED', 5], ['STALE_DELTA', 4]]}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': [['BASELINE_SEALED', 5], ['STALE_DELTA', 4]]}]), ('ordered trace 3', 'copying', ['copy_cancelled', 'baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'delta', 'source_reset', 'baseline_offer'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 5]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 5]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [5, 6, 7, 8, 9, 10, 11], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': [['BASELINE_SEALED', 5]]}, {'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': [['BASELINE_SEALED', 5]]}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': [['BASELINE_SEALED', 5]]}]), ('empty input', 'empty', [], []), ('unknown event', 'empty', ['unsupported'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, '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 = {'shadow': [seed] if phase in ('copying','replaying') else [], 'live': [seed-1] if phase in ('copying','replaying','live') else [], 'deltas': payload[:], 'published': phase=='live', 'notifications': []}
    frames = []
    observed = []
    table = {('empty', 'baseline_offer'): ('copying', 'create_shadow'), ('copying', 'baseline_item'): ('copying', 'write_shadow'), ('copying', 'concurrent_delta'): ('copying', 'buffer_after_cut'), ('copying', 'baseline_end'): ('replaying', 'seal_shadow'), ('replaying', 'delta'): ('replaying', 'apply_buffered_order'), ('replaying', 'buffer_empty'): ('live', 'merge_with_old'), ('live', 'source_reset'): ('empty', 'invalidate_baseline'), ('live', 'old_generation_delta'): ('live', 'reject_stale'), ('copying', 'copy_cancelled'): ('empty', 'discard_shadow'), ('live', 'delta'): ('live', 'apply_notify')}
    for event in events:
        phase, action = table.get((phase, event), (phase, "reject"))
        if action == 'create_shadow':
            r['shadow']=[]
        elif action == 'write_shadow':
            r['shadow'].extend(payload)
        elif action == 'buffer_after_cut':
            r['deltas'].extend(payload)
        elif action == 'seal_shadow':
            frames.append(['BASELINE_SEALED',seed])
        elif action == 'apply_buffered_order':
            r['shadow'].extend(r['deltas']); r['deltas']=[]
        elif action == 'atomic_publish':
            r['live']=r['shadow'][:]; r['published']=True
        elif action == 'invalidate_baseline':
            r['live']=[]; r['published']=False
        elif action == 'reject_stale':
            frames.append(['STALE_DELTA',seed-1])
        elif action == 'discard_shadow':
            r['shadow']=[]
        elif action == 'apply_notify':
            r['live'].extend(payload); r['notifications'].append(payload)
        elif action == 'accept_deltas':
            r['live'].extend(payload)
        elif action == 'write_live':
            r['live'].extend(payload)
        elif action == 'replace_shadow':
            r['shadow']=payload[:]
        elif action == 'drop_delta':
            r['deltas']=[]
        elif action == 'apply_before_baseline':
            r['shadow'].extend(payload)
        elif action == 'publish_shadow':
            r['live']=r['shadow'][:]; r['published']=True
        elif action == 'discard_deltas':
            r['deltas']=[]
        elif action == 'apply_reverse':
            r['shadow'].extend(reversed(r['deltas'])); r['deltas']=[]
        elif action == 'publish_early':
            r['live']=r['shadow'][:]; r['published']=True
        elif action == 'merge_with_old':
            r['live'].extend(r['shadow']); r['published']=True
        elif action == 'apply_delta':
            r['live'].extend(payload)
        elif action == 'restart_from_delta':
            r['shadow']=payload[:]
        elif action == 'buffer_forever':
            r['deltas'].extend(payload)
        elif action == 'apply_silent':
            r['live'].extend(payload)
        elif action == 'continue':
            r['live'].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: [('empty/baseline_offer', 'empty', ['baseline_offer'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_item', 'copying', ['baseline_item'], [{'phase': 'copying', 'registers': {'shadow': [1, 1, 2, 3], 'live': [0], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/concurrent_delta', 'copying', ['concurrent_delta'], [{'phase': 'copying', 'registers': {'shadow': [1], 'live': [0], 'deltas': [1, 2, 3, 1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_end', 'copying', ['baseline_end'], [{'phase': 'replaying', 'registers': {'shadow': [1], 'live': [0], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 1]]}]), ('replaying/delta', 'replaying', ['delta'], [{'phase': 'replaying', 'registers': {'shadow': [1, 1, 2, 3], 'live': [0], 'deltas': [], 'published': False, 'notifications': []}, 'frames': []}]), ('replaying/buffer_empty', 'replaying', ['buffer_empty'], [{'phase': 'live', 'registers': {'shadow': [1], 'live': [1], 'deltas': [1, 2, 3], 'published': True, 'notifications': []}, 'frames': []}]), ('live/source_reset', 'live', ['source_reset'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}]), ('live/old_generation_delta', 'live', ['old_generation_delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [0], 'deltas': [1, 2, 3], 'published': True, 'notifications': []}, 'frames': [['STALE_DELTA', 0]]}]), ('copying/copy_cancelled', 'copying', ['copy_cancelled'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [0], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}]), ('live/delta', 'live', ['delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [0, 1, 2, 3], 'deltas': [1, 2, 3], 'published': True, 'notifications': [[1, 2, 3]]}, 'frames': []}]), ('ordered trace 0', 'empty', ['baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3, 1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3, 1, 2, 3], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 1]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3, 1, 2, 3], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 1]]}]), ('ordered trace 3', 'copying', ['copy_cancelled', 'baseline_offer', 'concurrent_delta', 'baseline_end'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [0], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [0], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [0], 'deltas': [1, 2, 3, 1, 2, 3], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [0], 'deltas': [1, 2, 3, 1, 2, 3], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 1]]}]), ('empty input', 'empty', [], []), ('unknown event', 'empty', ['unsupported'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [1, 2, 3], 'published': False, 'notifications': []}, 'frames': [['reject', [1, 2, 3]]]}])], 2: [('empty/baseline_offer', 'empty', ['baseline_offer'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_item', 'copying', ['baseline_item'], [{'phase': 'copying', 'registers': {'shadow': [2, 2, 3, 4, 5], 'live': [1], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/concurrent_delta', 'copying', ['concurrent_delta'], [{'phase': 'copying', 'registers': {'shadow': [2], 'live': [1], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_end', 'copying', ['baseline_end'], [{'phase': 'replaying', 'registers': {'shadow': [2], 'live': [1], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 2]]}]), ('replaying/delta', 'replaying', ['delta'], [{'phase': 'replaying', 'registers': {'shadow': [2, 2, 3, 4, 5], 'live': [1], 'deltas': [], 'published': False, 'notifications': []}, 'frames': []}]), ('replaying/buffer_empty', 'replaying', ['buffer_empty'], [{'phase': 'live', 'registers': {'shadow': [2], 'live': [2], 'deltas': [2, 3, 4, 5], 'published': True, 'notifications': []}, 'frames': []}]), ('live/source_reset', 'live', ['source_reset'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}]), ('live/old_generation_delta', 'live', ['old_generation_delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [1], 'deltas': [2, 3, 4, 5], 'published': True, 'notifications': []}, 'frames': [['STALE_DELTA', 1]]}]), ('copying/copy_cancelled', 'copying', ['copy_cancelled'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [1], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}]), ('live/delta', 'live', ['delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [1, 2, 3, 4, 5], 'deltas': [2, 3, 4, 5], 'published': True, 'notifications': [[2, 3, 4, 5]]}, 'frames': []}]), ('ordered trace 0', 'empty', ['baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'old_generation_delta'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 2]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 2]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 2], ['STALE_DELTA', 1]]}]), ('ordered trace 3', 'copying', ['copy_cancelled', 'baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [1], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [1], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [1], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [1], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 2]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5, 2, 3, 4, 5], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 2]]}]), ('empty input', 'empty', [], []), ('unknown event', 'empty', ['unsupported'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [2, 3, 4, 5], 'published': False, 'notifications': []}, 'frames': [['reject', [2, 3, 4, 5]]]}])], 3: [('empty/baseline_offer', 'empty', ['baseline_offer'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_item', 'copying', ['baseline_item'], [{'phase': 'copying', 'registers': {'shadow': [3, 3, 4, 5, 6, 7], 'live': [2], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/concurrent_delta', 'copying', ['concurrent_delta'], [{'phase': 'copying', 'registers': {'shadow': [3], 'live': [2], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_end', 'copying', ['baseline_end'], [{'phase': 'replaying', 'registers': {'shadow': [3], 'live': [2], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 3]]}]), ('replaying/delta', 'replaying', ['delta'], [{'phase': 'replaying', 'registers': {'shadow': [3, 3, 4, 5, 6, 7], 'live': [2], 'deltas': [], 'published': False, 'notifications': []}, 'frames': []}]), ('replaying/buffer_empty', 'replaying', ['buffer_empty'], [{'phase': 'live', 'registers': {'shadow': [3], 'live': [3], 'deltas': [3, 4, 5, 6, 7], 'published': True, 'notifications': []}, 'frames': []}]), ('live/source_reset', 'live', ['source_reset'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}]), ('live/old_generation_delta', 'live', ['old_generation_delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [2], 'deltas': [3, 4, 5, 6, 7], 'published': True, 'notifications': []}, 'frames': [['STALE_DELTA', 2]]}]), ('copying/copy_cancelled', 'copying', ['copy_cancelled'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [2], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}]), ('live/delta', 'live', ['delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [2, 3, 4, 5, 6, 7], 'deltas': [3, 4, 5, 6, 7], 'published': True, 'notifications': [[3, 4, 5, 6, 7]]}, 'frames': []}]), ('ordered trace 0', 'empty', ['baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'old_generation_delta', 'delta'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 3]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 3]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 3], ['STALE_DELTA', 2]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [3, 4, 5, 6, 7], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': True, 'notifications': [[3, 4, 5, 6, 7]]}, 'frames': [['BASELINE_SEALED', 3], ['STALE_DELTA', 2]]}]), ('ordered trace 3', 'copying', ['copy_cancelled', 'baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'delta'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [2], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [2], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [2], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [2], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 3]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 3]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [3, 4, 5, 6, 7], 'deltas': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'published': True, 'notifications': [[3, 4, 5, 6, 7]]}, 'frames': [['BASELINE_SEALED', 3]]}]), ('empty input', 'empty', [], []), ('unknown event', 'empty', ['unsupported'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [3, 4, 5, 6, 7], 'published': False, 'notifications': []}, 'frames': [['reject', [3, 4, 5, 6, 7]]]}])], 4: [('empty/baseline_offer', 'empty', ['baseline_offer'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_item', 'copying', ['baseline_item'], [{'phase': 'copying', 'registers': {'shadow': [4, 4, 5, 6, 7, 8, 9], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/concurrent_delta', 'copying', ['concurrent_delta'], [{'phase': 'copying', 'registers': {'shadow': [4], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_end', 'copying', ['baseline_end'], [{'phase': 'replaying', 'registers': {'shadow': [4], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 4]]}]), ('replaying/delta', 'replaying', ['delta'], [{'phase': 'replaying', 'registers': {'shadow': [4, 4, 5, 6, 7, 8, 9], 'live': [3], 'deltas': [], 'published': False, 'notifications': []}, 'frames': []}]), ('replaying/buffer_empty', 'replaying', ['buffer_empty'], [{'phase': 'live', 'registers': {'shadow': [4], 'live': [4], 'deltas': [4, 5, 6, 7, 8, 9], 'published': True, 'notifications': []}, 'frames': []}]), ('live/source_reset', 'live', ['source_reset'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}]), ('live/old_generation_delta', 'live', ['old_generation_delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9], 'published': True, 'notifications': []}, 'frames': [['STALE_DELTA', 3]]}]), ('copying/copy_cancelled', 'copying', ['copy_cancelled'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}]), ('live/delta', 'live', ['delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [3, 4, 5, 6, 7, 8, 9], 'deltas': [4, 5, 6, 7, 8, 9], 'published': True, 'notifications': [[4, 5, 6, 7, 8, 9]]}, 'frames': []}]), ('ordered trace 0', 'empty', ['baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'old_generation_delta', 'delta', 'source_reset'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 4]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 4]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 4], ['STALE_DELTA', 3]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [4, 5, 6, 7, 8, 9], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': True, 'notifications': [[4, 5, 6, 7, 8, 9]]}, 'frames': [['BASELINE_SEALED', 4], ['STALE_DELTA', 3]]}, {'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': [[4, 5, 6, 7, 8, 9]]}, 'frames': [['BASELINE_SEALED', 4], ['STALE_DELTA', 3]]}]), ('ordered trace 3', 'copying', ['copy_cancelled', 'baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'delta', 'source_reset'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [3], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 4]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 4]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [4, 5, 6, 7, 8, 9], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': True, 'notifications': [[4, 5, 6, 7, 8, 9]]}, 'frames': [['BASELINE_SEALED', 4]]}, {'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'published': False, 'notifications': [[4, 5, 6, 7, 8, 9]]}, 'frames': [['BASELINE_SEALED', 4]]}]), ('empty input', 'empty', [], []), ('unknown event', 'empty', ['unsupported'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [4, 5, 6, 7, 8, 9], 'published': False, 'notifications': []}, 'frames': [['reject', [4, 5, 6, 7, 8, 9]]]}])], 5: [('empty/baseline_offer', 'empty', ['baseline_offer'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_item', 'copying', ['baseline_item'], [{'phase': 'copying', 'registers': {'shadow': [5, 5, 6, 7, 8, 9, 10, 11], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/concurrent_delta', 'copying', ['concurrent_delta'], [{'phase': 'copying', 'registers': {'shadow': [5], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}]), ('copying/baseline_end', 'copying', ['baseline_end'], [{'phase': 'replaying', 'registers': {'shadow': [5], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 5]]}]), ('replaying/delta', 'replaying', ['delta'], [{'phase': 'replaying', 'registers': {'shadow': [5, 5, 6, 7, 8, 9, 10, 11], 'live': [4], 'deltas': [], 'published': False, 'notifications': []}, 'frames': []}]), ('replaying/buffer_empty', 'replaying', ['buffer_empty'], [{'phase': 'live', 'registers': {'shadow': [5], 'live': [5], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': []}, 'frames': []}]), ('live/source_reset', 'live', ['source_reset'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}]), ('live/old_generation_delta', 'live', ['old_generation_delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': []}, 'frames': [['STALE_DELTA', 4]]}]), ('copying/copy_cancelled', 'copying', ['copy_cancelled'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}]), ('live/delta', 'live', ['delta'], [{'phase': 'live', 'registers': {'shadow': [], 'live': [4, 5, 6, 7, 8, 9, 10, 11], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': []}]), ('ordered trace 0', 'empty', ['baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'old_generation_delta', 'delta', 'source_reset', 'baseline_offer'], [{'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 5]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 5]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 5], ['STALE_DELTA', 4]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [5, 6, 7, 8, 9, 10, 11], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': [['BASELINE_SEALED', 5], ['STALE_DELTA', 4]]}, {'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': [['BASELINE_SEALED', 5], ['STALE_DELTA', 4]]}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': [['BASELINE_SEALED', 5], ['STALE_DELTA', 4]]}]), ('ordered trace 3', 'copying', ['copy_cancelled', 'baseline_offer', 'concurrent_delta', 'baseline_end', 'buffer_empty', 'delta', 'source_reset', 'baseline_offer'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': []}, {'phase': 'replaying', 'registers': {'shadow': [], 'live': [4], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, 'frames': [['BASELINE_SEALED', 5]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': []}, 'frames': [['BASELINE_SEALED', 5]]}, {'phase': 'live', 'registers': {'shadow': [], 'live': [5, 6, 7, 8, 9, 10, 11], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': True, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': [['BASELINE_SEALED', 5]]}, {'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': [['BASELINE_SEALED', 5]]}, {'phase': 'copying', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': [[5, 6, 7, 8, 9, 10, 11]]}, 'frames': [['BASELINE_SEALED', 5]]}]), ('empty input', 'empty', [], []), ('unknown event', 'empty', ['unsupported'], [{'phase': 'empty', 'registers': {'shadow': [], 'live': [], 'deltas': [5, 6, 7, 8, 9, 10, 11], 'published': False, 'notifications': []}, '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 replaying, event buffer_empty produces replaying/wait instead of live/atomic_publish.

For the stipulated Mirror baseline and delta cutover 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