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

N = 1
observations = []
def solve(s):
    return {
        'depth': max(0,s['pauses']+int(s['pause'])-int(s['resume'])),
        'hold': s['pauses']>0 and s['buffer'] and not s['closed'] and s['incoming'] is not None,
        'resume': s['resume'] and s['pauses']==1 and not s['closed'],
        'drain': list(s['queued']) if s['resume'] and s['pauses']==1 and not s['closed'] and not s['drained'] else [],
        'drops': s['drops'],
        'retain': s['queued'][-s['capacity']:] if s['capacity']>0 and not s['closed'] else [],
        'deliver': s['pauses']==0 and not s['closed'] and s['incoming'] is not None,
        'clear': s['closed'] or (s['resume'] and s['pauses']==1 and not s['drained']),
        'overflow': max(0,len(s['queued'])+int(s['incoming'] is not None)-s['capacity']),
        'redundant_resume': s['resume'] and s['pauses']==0,
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 3, 'drops': 2, 'drained': False}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 3, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': 'new', 'capacity': 1, 'drops': 2, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 0, 'drops': 2, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 3, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 0, 'drops': 2, 'drained': False}, {'depth': 3, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 3, 'drops': 2, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': True}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 3, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 3, 'drops': 2, 'drained': True}, {'depth': 3, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False})], 2: [({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 6, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 0, 'drops': 4, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 4, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': True}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 6, 'drops': 4, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 4, 'retain': ['a', 'b', 'c'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': True, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 1, 'drops': 4, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 6, 'pause': False, 'resume': False, 'closed': False, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': ['a'], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 6, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 6, 'drops': 4, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 3: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 0, 'drops': 6, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 9, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 8, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 9, 'drops': 6, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': True}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 1, 'drops': 6, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 6, 'retain': ['c'], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 9, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 0, 'drops': 6, 'drained': False}, {'depth': 9, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': True, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 9, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 9, 'drops': 6, 'drained': True}, {'depth': 9, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 4: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 12, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 11, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 8, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a'], 'incoming': None, 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': ['a'], 'drops': 0, 'retain': ['a'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 12, 'drops': 0, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 0, 'retain': ['a', 'b', 'c'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': False, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 8, 'drained': False}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 12, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 12, 'drops': 8, 'drained': True}, {'depth': 12, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 5: [({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 15, 'pause': False, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 1, 'drops': 10, 'drained': False}, {'depth': 14, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': False, 'queued': [], 'incoming': 'new', 'capacity': 0, 'drops': 10, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': [], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': False, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 10, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 11, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': False, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 15, 'drops': 10, 'drained': True}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 15, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 15, 'drops': 10, 'drained': True}, {'depth': 15, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})]}
for i,(state,expected) in enumerate(fixtures[N]):
    check("transition "+str(i), solve(state), 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(s):
    return {
        'depth': max(0,s['pauses']+int(s['pause'])-int(s['resume'])),
        'hold': s['pauses']>0 and s['buffer'] and not s['closed'] and s['incoming'] is not None,
        'resume': s['resume'] and s['pauses']==1 and not s['closed'],
        'drain': list(s['queued']) if s['resume'] and s['pauses']==1 and not s['closed'] and not s['drained'] else [],
        'drops': s['drops']+int(s['pauses']>0),
        'retain': s['queued'][-s['capacity']:] if s['capacity']>0 and not s['closed'] else [],
        'deliver': s['pauses']==0 and not s['closed'] and s['incoming'] is not None,
        'clear': s['closed'] or (s['resume'] and s['pauses']==1 and not s['drained']),
        'overflow': max(0,len(s['queued'])+int(s['incoming'] is not None)-s['capacity']),
        'redundant_resume': s['resume'] and s['pauses']==0,
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 3, 'drops': 2, 'drained': False}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 3, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': 'new', 'capacity': 1, 'drops': 2, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 0, 'drops': 2, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 3, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 0, 'drops': 2, 'drained': False}, {'depth': 3, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 3, 'drops': 2, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': True}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 3, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 3, 'drops': 2, 'drained': True}, {'depth': 3, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False})], 2: [({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 6, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 0, 'drops': 4, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 4, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': True}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 6, 'drops': 4, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 4, 'retain': ['a', 'b', 'c'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': True, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 1, 'drops': 4, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 6, 'pause': False, 'resume': False, 'closed': False, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': ['a'], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 6, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 6, 'drops': 4, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 3: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 0, 'drops': 6, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 9, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 8, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 9, 'drops': 6, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': True}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 1, 'drops': 6, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 6, 'retain': ['c'], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 9, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 0, 'drops': 6, 'drained': False}, {'depth': 9, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': True, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 9, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 9, 'drops': 6, 'drained': True}, {'depth': 9, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 4: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 12, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 11, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 8, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a'], 'incoming': None, 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': ['a'], 'drops': 0, 'retain': ['a'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 12, 'drops': 0, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 0, 'retain': ['a', 'b', 'c'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': False, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 8, 'drained': False}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 12, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 12, 'drops': 8, 'drained': True}, {'depth': 12, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 5: [({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 15, 'pause': False, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 1, 'drops': 10, 'drained': False}, {'depth': 14, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': False, 'queued': [], 'incoming': 'new', 'capacity': 0, 'drops': 10, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': [], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': False, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 10, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 11, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': False, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 15, 'drops': 10, 'drained': True}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 15, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 15, 'drops': 10, 'drained': True}, {'depth': 15, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})]}
for i,(state,expected) in enumerate(fixtures[N]):
    check("transition "+str(i), solve(state), 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:
Paused discard mode forgets to record a dropped event; the returned lifecycle plan violates the stated transition contract.

Plan pausing/resuming a subscription. A nested pause counter never underflows. While paused, buffer only if buffering was requested; otherwise count the dropped events. Resume drains in arrival order only when the last pause ends. A closed subscription neither buffers nor resumes. Overflow retains the newest bounded suffix. Inputs are finite state snapshots, including transitional and stale states; output fields are the exact independent actions/metadata defined by the corrected expression table. Numeric fixture capacities and counts vary with N.
Field definitions, each independently computed from the input snapshot: depth = max(0,s['pauses']+int(s['pause'])-int(s['resume'])); hold = s['pauses']>0 and s['buffer'] and not s['closed'] and s['incoming'] is not None; resume = s['resume'] and s['pauses']==1 and not s['closed']; drain = list(s['queued']) if s['resume'] and s['pauses']==1 and not s['closed'] and not s['drained'] else []; drops = s['drops']+int(s['pauses']>0 and not s['buffer'] and s['incoming'] is not None); retain = s['queued'][-s['capacity']:] if s['capacity']>0 and not s['closed'] else []; deliver = s['pauses']==0 and not s['closed'] and s['incoming'] is not None; clear = s['closed'] or (s['resume'] and s['pauses']==1 and not s['drained']); overflow = max(0,len(s['queued'])+int(s['incoming'] is not None)-s['capacity']); redundant_resume = s['resume'] and s['pauses']==0

split: open-access


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

N = 1
observations = []
def solve(s):
    return {
        'depth': max(0,s['pauses']+int(s['pause'])-int(s['resume'])),
        'hold': s['pauses']>0 and s['buffer'] and not s['closed'] and s['incoming'] is not None,
        'resume': s['resume'] and s['pauses']==1 and not s['closed'],
        'drain': list(s['queued']) if s['resume'] and s['pauses']==1 and not s['closed'] and not s['drained'] else [],
        'drops': s['drops']+int(s['pauses']>0 and not s['buffer'] and s['incoming'] is not None),
        'retain': s['queued'][-s['capacity']:],
        'deliver': s['pauses']==0 and not s['closed'] and s['incoming'] is not None,
        'clear': s['closed'] or (s['resume'] and s['pauses']==1 and not s['drained']),
        'overflow': max(0,len(s['queued'])+int(s['incoming'] is not None)-s['capacity']),
        'redundant_resume': s['resume'] and s['pauses']==0,
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 3, 'drops': 2, 'drained': False}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 3, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': 'new', 'capacity': 1, 'drops': 2, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 0, 'drops': 2, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 3, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 0, 'drops': 2, 'drained': False}, {'depth': 3, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 3, 'drops': 2, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': True}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 3, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 3, 'drops': 2, 'drained': True}, {'depth': 3, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False})], 2: [({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 6, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 0, 'drops': 4, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 4, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': True}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 6, 'drops': 4, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 4, 'retain': ['a', 'b', 'c'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': True, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 1, 'drops': 4, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 6, 'pause': False, 'resume': False, 'closed': False, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': ['a'], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 6, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 6, 'drops': 4, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 3: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 0, 'drops': 6, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 9, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 8, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 9, 'drops': 6, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': True}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 1, 'drops': 6, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 6, 'retain': ['c'], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 9, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 0, 'drops': 6, 'drained': False}, {'depth': 9, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': True, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 9, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 9, 'drops': 6, 'drained': True}, {'depth': 9, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 4: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 12, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 11, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 8, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a'], 'incoming': None, 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': ['a'], 'drops': 0, 'retain': ['a'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 12, 'drops': 0, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 0, 'retain': ['a', 'b', 'c'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': False, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 8, 'drained': False}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 12, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 12, 'drops': 8, 'drained': True}, {'depth': 12, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 5: [({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 15, 'pause': False, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 1, 'drops': 10, 'drained': False}, {'depth': 14, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': False, 'queued': [], 'incoming': 'new', 'capacity': 0, 'drops': 10, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': [], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': False, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 10, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 11, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': False, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 15, 'drops': 10, 'drained': True}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 15, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 15, 'drops': 10, 'drained': True}, {'depth': 15, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})]}
for i,(state,expected) in enumerate(fixtures[N]):
    check("transition "+str(i), solve(state), 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(s):
    return {
        'depth': max(0,s['pauses']+int(s['pause'])-int(s['resume'])),
        'hold': s['pauses']>0 and s['buffer'] and not s['closed'] and s['incoming'] is not None,
        'resume': s['resume'] and s['pauses']==1 and not s['closed'],
        'drain': list(s['queued']) if s['resume'] and s['pauses']==1 and not s['closed'] and not s['drained'] else [],
        'drops': s['drops']+int(s['pauses']>0 and not s['buffer'] and s['incoming'] is not None),
        'retain': s['queued'][:s['capacity']] if not s['closed'] else [],
        'deliver': s['pauses']==0 and not s['closed'] and s['incoming'] is not None,
        'clear': s['closed'] or (s['resume'] and s['pauses']==1 and not s['drained']),
        'overflow': max(0,len(s['queued'])+int(s['incoming'] is not None)-s['capacity']),
        'redundant_resume': s['resume'] and s['pauses']==0,
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 3, 'drops': 2, 'drained': False}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 3, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': 'new', 'capacity': 1, 'drops': 2, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 0, 'drops': 2, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 3, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 0, 'drops': 2, 'drained': False}, {'depth': 3, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 3, 'drops': 2, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': True}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 3, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 3, 'drops': 2, 'drained': True}, {'depth': 3, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False})], 2: [({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 6, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 0, 'drops': 4, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 4, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': True}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 6, 'drops': 4, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 4, 'retain': ['a', 'b', 'c'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': True, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 1, 'drops': 4, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 6, 'pause': False, 'resume': False, 'closed': False, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': ['a'], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 6, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 6, 'drops': 4, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 3: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 0, 'drops': 6, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 9, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 8, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 9, 'drops': 6, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': True}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 1, 'drops': 6, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 6, 'retain': ['c'], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 9, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 0, 'drops': 6, 'drained': False}, {'depth': 9, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': True, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 9, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 9, 'drops': 6, 'drained': True}, {'depth': 9, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 4: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 12, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 11, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 8, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a'], 'incoming': None, 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': ['a'], 'drops': 0, 'retain': ['a'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 12, 'drops': 0, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 0, 'retain': ['a', 'b', 'c'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': False, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 8, 'drained': False}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 12, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 12, 'drops': 8, 'drained': True}, {'depth': 12, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 5: [({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 15, 'pause': False, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 1, 'drops': 10, 'drained': False}, {'depth': 14, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': False, 'queued': [], 'incoming': 'new', 'capacity': 0, 'drops': 10, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': [], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': False, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 10, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 11, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': False, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 15, 'drops': 10, 'drained': True}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 15, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 15, 'drops': 10, 'drained': True}, {'depth': 15, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})]}
for i,(state,expected) in enumerate(fixtures[N]):
    check("transition "+str(i), solve(state), 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:
A zero-capacity pause buffer retains every queued event; the returned lifecycle plan violates the stated transition contract.

Plan pausing/resuming a subscription. A nested pause counter never underflows. While paused, buffer only if buffering was requested; otherwise count the dropped events. Resume drains in arrival order only when the last pause ends. A closed subscription neither buffers nor resumes. Overflow retains the newest bounded suffix. Inputs are finite state snapshots, including transitional and stale states; output fields are the exact independent actions/metadata defined by the corrected expression table. Numeric fixture capacities and counts vary with N.
Field definitions, each independently computed from the input snapshot: depth = max(0,s['pauses']+int(s['pause'])-int(s['resume'])); hold = s['pauses']>0 and s['buffer'] and not s['closed'] and s['incoming'] is not None; resume = s['resume'] and s['pauses']==1 and not s['closed']; drain = list(s['queued']) if s['resume'] and s['pauses']==1 and not s['closed'] and not s['drained'] else []; drops = s['drops']+int(s['pauses']>0 and not s['buffer'] and s['incoming'] is not None); retain = s['queued'][-s['capacity']:] if s['capacity']>0 and not s['closed'] else []; deliver = s['pauses']==0 and not s['closed'] and s['incoming'] is not None; clear = s['closed'] or (s['resume'] and s['pauses']==1 and not s['drained']); overflow = max(0,len(s['queued'])+int(s['incoming'] is not None)-s['capacity']); redundant_resume = s['resume'] and s['pauses']==0

split: open-access


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

N = 1
observations = []
def solve(s):
    return {
        'depth': max(0,s['pauses']+int(s['pause'])-int(s['resume'])),
        'hold': s['pauses']>0 and s['buffer'] and not s['closed'] and s['incoming'] is not None,
        'resume': s['resume'] and s['pauses']==1 and not s['closed'],
        'drain': list(s['queued']) if s['resume'] and s['pauses']==1 and not s['closed'] and not s['drained'] else [],
        'drops': s['drops']+int(s['pauses']>0 and not s['buffer'] and s['incoming'] is not None),
        'retain': s['queued'][-s['capacity']:] if s['capacity']>0 and not s['closed'] else [],
        'deliver': not s['closed'] and s['incoming'] is not None,
        'clear': s['closed'] or (s['resume'] and s['pauses']==1 and not s['drained']),
        'overflow': max(0,len(s['queued'])+int(s['incoming'] is not None)-s['capacity']),
        'redundant_resume': s['resume'] and s['pauses']==0,
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 3, 'drops': 2, 'drained': False}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 3, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': 'new', 'capacity': 1, 'drops': 2, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 0, 'drops': 2, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 3, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 0, 'drops': 2, 'drained': False}, {'depth': 3, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 3, 'drops': 2, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': True}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 3, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 3, 'drops': 2, 'drained': True}, {'depth': 3, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False})], 2: [({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 6, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 0, 'drops': 4, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 4, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': True}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 6, 'drops': 4, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 4, 'retain': ['a', 'b', 'c'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': True, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 1, 'drops': 4, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 6, 'pause': False, 'resume': False, 'closed': False, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': ['a'], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 6, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 6, 'drops': 4, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 3: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 0, 'drops': 6, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 9, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 8, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 9, 'drops': 6, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': True}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 1, 'drops': 6, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 6, 'retain': ['c'], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 9, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 0, 'drops': 6, 'drained': False}, {'depth': 9, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': True, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 9, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 9, 'drops': 6, 'drained': True}, {'depth': 9, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 4: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 12, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 11, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 8, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a'], 'incoming': None, 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': ['a'], 'drops': 0, 'retain': ['a'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 12, 'drops': 0, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 0, 'retain': ['a', 'b', 'c'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': False, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 8, 'drained': False}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 12, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 12, 'drops': 8, 'drained': True}, {'depth': 12, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 5: [({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 15, 'pause': False, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 1, 'drops': 10, 'drained': False}, {'depth': 14, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': False, 'queued': [], 'incoming': 'new', 'capacity': 0, 'drops': 10, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': [], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': False, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 10, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 11, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': False, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 15, 'drops': 10, 'drained': True}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 15, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 15, 'drops': 10, 'drained': True}, {'depth': 15, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})]}
for i,(state,expected) in enumerate(fixtures[N]):
    check("transition "+str(i), solve(state), 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(s):
    return {
        'depth': max(0,s['pauses']+int(s['pause'])-int(s['resume'])),
        'hold': s['pauses']>0 and s['buffer'] and not s['closed'] and s['incoming'] is not None,
        'resume': s['resume'] and s['pauses']==1 and not s['closed'],
        'drain': list(s['queued']) if s['resume'] and s['pauses']==1 and not s['closed'] and not s['drained'] else [],
        'drops': s['drops']+int(s['pauses']>0 and not s['buffer'] and s['incoming'] is not None),
        'retain': s['queued'][-s['capacity']:] if s['capacity']>0 and not s['closed'] else [],
        'deliver': s['pauses']==0 and s['incoming'] is not None,
        'clear': s['closed'] or (s['resume'] and s['pauses']==1 and not s['drained']),
        'overflow': max(0,len(s['queued'])+int(s['incoming'] is not None)-s['capacity']),
        'redundant_resume': s['resume'] and s['pauses']==0,
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 3, 'drops': 2, 'drained': False}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 3, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': 'new', 'capacity': 1, 'drops': 2, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 0, 'drops': 2, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 3, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 0, 'drops': 2, 'drained': False}, {'depth': 3, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 3, 'drops': 2, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': True}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 3, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 3, 'drops': 2, 'drained': True}, {'depth': 3, 'hold': False, 'resume': False, 'drain': [], 'drops': 2, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False})], 2: [({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 6, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 0, 'drops': 4, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 4, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': True}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 6, 'drops': 4, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 4, 'retain': ['a', 'b', 'c'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': True, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 1, 'drops': 4, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 6, 'pause': False, 'resume': False, 'closed': False, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': ['a'], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 6, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 6, 'drops': 4, 'drained': True}, {'depth': 6, 'hold': False, 'resume': False, 'drain': [], 'drops': 4, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 3: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': None, 'capacity': 0, 'drops': 6, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 9, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 8, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 9, 'drops': 6, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': True}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 1, 'drops': 6, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 6, 'retain': ['c'], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 9, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 0, 'drops': 6, 'drained': False}, {'depth': 9, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': True, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 9, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 9, 'drops': 6, 'drained': True}, {'depth': 9, 'hold': False, 'resume': False, 'drain': [], 'drops': 6, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 4: [({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 12, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 11, 'hold': False, 'resume': False, 'drain': [], 'drops': 1, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 3, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 1, 'drops': 8, 'drained': True}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 3, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a'], 'incoming': None, 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': ['a'], 'drops': 0, 'retain': ['a'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 12, 'drops': 0, 'drained': False}, {'depth': 1, 'hold': False, 'resume': True, 'drain': ['a', 'b', 'c'], 'drops': 0, 'retain': ['a', 'b', 'c'], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': False, 'closed': True, 'buffer': True, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 8, 'drained': False}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 12, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 12, 'drops': 8, 'drained': True}, {'depth': 12, 'hold': False, 'resume': False, 'drain': [], 'drops': 8, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})], 5: [({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 0, 'drained': True}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 15, 'pause': False, 'resume': True, 'closed': False, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': None, 'capacity': 1, 'drops': 10, 'drained': False}, {'depth': 14, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': ['c'], 'deliver': False, 'clear': False, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': True, 'closed': True, 'buffer': False, 'queued': [], 'incoming': 'new', 'capacity': 0, 'drops': 10, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 1, 'redundant_resume': True}), ({'pauses': 1, 'pause': False, 'resume': True, 'closed': False, 'buffer': False, 'queued': [], 'incoming': 'new', 'capacity': 1, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': True, 'drain': [], 'drops': 1, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': True, 'closed': True, 'buffer': False, 'queued': ['a'], 'incoming': 'new', 'capacity': 0, 'drops': 10, 'drained': True}, {'depth': 1, 'hold': False, 'resume': False, 'drain': [], 'drops': 11, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 2, 'redundant_resume': False}), ({'pauses': 1, 'pause': True, 'resume': False, 'closed': True, 'buffer': True, 'queued': [], 'incoming': 'new', 'capacity': 15, 'drops': 10, 'drained': True}, {'depth': 2, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 0, 'pause': False, 'resume': False, 'closed': False, 'buffer': False, 'queued': [], 'incoming': None, 'capacity': 0, 'drops': 0, 'drained': False}, {'depth': 0, 'hold': False, 'resume': False, 'drain': [], 'drops': 0, 'retain': [], 'deliver': False, 'clear': False, 'overflow': 0, 'redundant_resume': False}), ({'pauses': 15, 'pause': True, 'resume': True, 'closed': True, 'buffer': True, 'queued': ['a', 'b', 'c'], 'incoming': 'new', 'capacity': 15, 'drops': 10, 'drained': True}, {'depth': 15, 'hold': False, 'resume': False, 'drain': [], 'drops': 10, 'retain': [], 'deliver': False, 'clear': True, 'overflow': 0, 'redundant_resume': False})]}
for i,(state,expected) in enumerate(fixtures[N]):
    check("transition "+str(i), solve(state), 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:
Paused observers receive events directly despite their pause depth; the returned lifecycle plan violates the stated transition contract.

Plan pausing/resuming a subscription. A nested pause counter never underflows. While paused, buffer only if buffering was requested; otherwise count the dropped events. Resume drains in arrival order only when the last pause ends. A closed subscription neither buffers nor resumes. Overflow retains the newest bounded suffix. Inputs are finite state snapshots, including transitional and stale states; output fields are the exact independent actions/metadata defined by the corrected expression table. Numeric fixture capacities and counts vary with N.
Field definitions, each independently computed from the input snapshot: depth = max(0,s['pauses']+int(s['pause'])-int(s['resume'])); hold = s['pauses']>0 and s['buffer'] and not s['closed'] and s['incoming'] is not None; resume = s['resume'] and s['pauses']==1 and not s['closed']; drain = list(s['queued']) if s['resume'] and s['pauses']==1 and not s['closed'] and not s['drained'] else []; drops = s['drops']+int(s['pauses']>0 and not s['buffer'] and s['incoming'] is not None); retain = s['queued'][-s['capacity']:] if s['capacity']>0 and not s['closed'] else []; deliver = s['pauses']==0 and not s['closed'] and s['incoming'] is not None; clear = s['closed'] or (s['resume'] and s['pauses']==1 and not s['drained']); overflow = max(0,len(s['queued'])+int(s['incoming'] is not None)-s['capacity']); redundant_resume = s['resume'] and s['pauses']==0

split: open-access