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

N = 1
observations = []
def solve(s):
    return {
        'expired': s['now']>s['start']+s['width'],
        'start': s['now'] if not s['open'] or s['now']>=s['start']+s['width'] else s['start'],
        'leading_emit': s['leading'] and not s['used'] and s['incoming'] is not None,
        'trailing_payload': s['incoming'] if s['trailing'] and s['incoming'] is not None else s['pending'],
        'flush': s['trailing'] and s['pending'] is not None and s['open'] and s['now']>=s['start']+s['width'],
        'used': s['used'] or (s['leading'] and s['incoming'] is not None),
        'first_trailing': s['trailing'] and not s['leading'] and not s['open'] and s['incoming'] is not None,
        'remaining': max(0,s['start']+s['width']-s['now']),
        'reset_pending': s['pending'] if s['pending_sequence']>s['leading_sequence'] else None,
        'drop': s['incoming'] is not None and s['used'] and not s['trailing'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'now': 6, 'start': 0, 'width': 2, 'open': False, 'leading': False, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 2, 'leading_sequence': 2}, {'expired': True, 'start': 6, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 2, 'width': 5, 'open': True, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 4, 'leading_sequence': 0}, {'expired': False, 'start': 2, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 1, 'reset_pending': 'old', 'drop': False}), ({'now': 2, 'start': 2, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 0, 'leading_sequence': 2}, {'expired': True, 'start': 2, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 2, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': 'old', 'drop': False}), ({'now': 2, 'start': 6, 'width': 2, 'open': True, 'leading': True, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 4}, {'expired': False, 'start': 6, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 6, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 6, 'width': 0, 'open': True, 'leading': False, 'trailing': True, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 2}, {'expired': True, 'start': 6, 'leading_emit': False, 'trailing_payload': 'old', 'flush': True, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 6, 'width': 5, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 4, 'leading_sequence': 4}, {'expired': False, 'start': 6, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 5, 'reset_pending': None, 'drop': False})], 2: [({'now': 12, 'start': 4, 'width': 4, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': True, 'start': 12, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 12, 'start': 12, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 4, 'leading_sequence': 8}, {'expired': True, 'start': 12, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 4, 'start': 0, 'width': 10, 'open': True, 'leading': True, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 4}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 6, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 12, 'width': 4, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': True, 'remaining': 16, 'reset_pending': None, 'drop': False}), ({'now': 4, 'start': 12, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': True, 'pending_sequence': 0, 'leading_sequence': 4}, {'expired': False, 'start': 4, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 8, 'reset_pending': None, 'drop': False}), ({'now': 4, 'start': 12, 'width': 10, 'open': False, 'leading': True, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': True, 'pending_sequence': 4, 'leading_sequence': 4}, {'expired': False, 'start': 4, 'leading_emit': True, 'trailing_payload': None, 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 18, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 12, 'start': 12, 'width': 10, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': False, 'start': 12, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 10, 'reset_pending': None, 'drop': False})], 3: [({'now': 18, 'start': 0, 'width': 6, 'open': False, 'leading': False, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 18, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 6, 'leading_sequence': 12}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 6, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 6, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 18, 'width': 6, 'open': True, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 12, 'leading_sequence': 6}, {'expired': False, 'start': 18, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 24, 'reset_pending': 'old', 'drop': False}), ({'now': 0, 'start': 18, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 0, 'leading_sequence': 12}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 18, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 6, 'width': 0, 'open': True, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 12, 'leading_sequence': 6}, {'expired': True, 'start': 6, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 18, 'start': 18, 'width': 15, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 12, 'leading_sequence': 12}, {'expired': False, 'start': 18, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 15, 'reset_pending': None, 'drop': False})], 4: [({'now': 24, 'start': 0, 'width': 8, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 24, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 0, 'width': 20, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': None, 'flushed': True, 'pending_sequence': 16, 'leading_sequence': 0}, {'expired': False, 'start': 8, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 12, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 8, 'width': 0, 'open': True, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 16, 'leading_sequence': 0}, {'expired': True, 'start': 8, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': 'old', 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 8, 'width': 8, 'open': True, 'leading': True, 'trailing': False, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 16, 'leading_sequence': 16}, {'expired': False, 'start': 8, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 8, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 0, 'width': 20, 'open': True, 'leading': True, 'trailing': True, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 8, 'leading_sequence': 16}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 12, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 24, 'start': 24, 'width': 20, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 16, 'leading_sequence': 16}, {'expired': False, 'start': 24, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 20, 'reset_pending': None, 'drop': False})], 5: [({'now': 30, 'start': 10, 'width': 10, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 20}, {'expired': True, 'start': 30, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 30, 'start': 30, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 10}, {'expired': True, 'start': 30, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 10, 'start': 0, 'width': 25, 'open': True, 'leading': False, 'trailing': False, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 20}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 15, 'reset_pending': None, 'drop': True}), ({'now': 0, 'start': 10, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': None, 'flushed': True, 'pending_sequence': 10, 'leading_sequence': 20}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 10, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 30, 'width': 0, 'open': True, 'leading': False, 'trailing': True, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 0}, {'expired': False, 'start': 30, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 30, 'reset_pending': 'old', 'drop': False}), ({'now': 0, 'start': 10, 'width': 25, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 20}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 35, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 30, 'start': 30, 'width': 25, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 20}, {'expired': False, 'start': 30, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 25, 'reset_pending': None, 'drop': 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 {
        'expired': s['now']>=s['start'],
        'start': s['now'] if not s['open'] or s['now']>=s['start']+s['width'] else s['start'],
        'leading_emit': s['leading'] and not s['used'] and s['incoming'] is not None,
        'trailing_payload': s['incoming'] if s['trailing'] and s['incoming'] is not None else s['pending'],
        'flush': s['trailing'] and s['pending'] is not None and s['open'] and s['now']>=s['start']+s['width'],
        'used': s['used'] or (s['leading'] and s['incoming'] is not None),
        'first_trailing': s['trailing'] and not s['leading'] and not s['open'] and s['incoming'] is not None,
        'remaining': max(0,s['start']+s['width']-s['now']),
        'reset_pending': s['pending'] if s['pending_sequence']>s['leading_sequence'] else None,
        'drop': s['incoming'] is not None and s['used'] and not s['trailing'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'now': 6, 'start': 0, 'width': 2, 'open': False, 'leading': False, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 2, 'leading_sequence': 2}, {'expired': True, 'start': 6, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 2, 'width': 5, 'open': True, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 4, 'leading_sequence': 0}, {'expired': False, 'start': 2, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 1, 'reset_pending': 'old', 'drop': False}), ({'now': 2, 'start': 2, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 0, 'leading_sequence': 2}, {'expired': True, 'start': 2, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 2, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': 'old', 'drop': False}), ({'now': 2, 'start': 6, 'width': 2, 'open': True, 'leading': True, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 4}, {'expired': False, 'start': 6, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 6, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 6, 'width': 0, 'open': True, 'leading': False, 'trailing': True, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 2}, {'expired': True, 'start': 6, 'leading_emit': False, 'trailing_payload': 'old', 'flush': True, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 6, 'width': 5, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 4, 'leading_sequence': 4}, {'expired': False, 'start': 6, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 5, 'reset_pending': None, 'drop': False})], 2: [({'now': 12, 'start': 4, 'width': 4, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': True, 'start': 12, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 12, 'start': 12, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 4, 'leading_sequence': 8}, {'expired': True, 'start': 12, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 4, 'start': 0, 'width': 10, 'open': True, 'leading': True, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 4}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 6, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 12, 'width': 4, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': True, 'remaining': 16, 'reset_pending': None, 'drop': False}), ({'now': 4, 'start': 12, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': True, 'pending_sequence': 0, 'leading_sequence': 4}, {'expired': False, 'start': 4, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 8, 'reset_pending': None, 'drop': False}), ({'now': 4, 'start': 12, 'width': 10, 'open': False, 'leading': True, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': True, 'pending_sequence': 4, 'leading_sequence': 4}, {'expired': False, 'start': 4, 'leading_emit': True, 'trailing_payload': None, 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 18, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 12, 'start': 12, 'width': 10, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': False, 'start': 12, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 10, 'reset_pending': None, 'drop': False})], 3: [({'now': 18, 'start': 0, 'width': 6, 'open': False, 'leading': False, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 18, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 6, 'leading_sequence': 12}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 6, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 6, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 18, 'width': 6, 'open': True, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 12, 'leading_sequence': 6}, {'expired': False, 'start': 18, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 24, 'reset_pending': 'old', 'drop': False}), ({'now': 0, 'start': 18, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 0, 'leading_sequence': 12}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 18, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 6, 'width': 0, 'open': True, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 12, 'leading_sequence': 6}, {'expired': True, 'start': 6, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 18, 'start': 18, 'width': 15, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 12, 'leading_sequence': 12}, {'expired': False, 'start': 18, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 15, 'reset_pending': None, 'drop': False})], 4: [({'now': 24, 'start': 0, 'width': 8, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 24, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 0, 'width': 20, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': None, 'flushed': True, 'pending_sequence': 16, 'leading_sequence': 0}, {'expired': False, 'start': 8, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 12, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 8, 'width': 0, 'open': True, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 16, 'leading_sequence': 0}, {'expired': True, 'start': 8, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': 'old', 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 8, 'width': 8, 'open': True, 'leading': True, 'trailing': False, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 16, 'leading_sequence': 16}, {'expired': False, 'start': 8, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 8, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 0, 'width': 20, 'open': True, 'leading': True, 'trailing': True, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 8, 'leading_sequence': 16}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 12, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 24, 'start': 24, 'width': 20, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 16, 'leading_sequence': 16}, {'expired': False, 'start': 24, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 20, 'reset_pending': None, 'drop': False})], 5: [({'now': 30, 'start': 10, 'width': 10, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 20}, {'expired': True, 'start': 30, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 30, 'start': 30, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 10}, {'expired': True, 'start': 30, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 10, 'start': 0, 'width': 25, 'open': True, 'leading': False, 'trailing': False, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 20}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 15, 'reset_pending': None, 'drop': True}), ({'now': 0, 'start': 10, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': None, 'flushed': True, 'pending_sequence': 10, 'leading_sequence': 20}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 10, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 30, 'width': 0, 'open': True, 'leading': False, 'trailing': True, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 0}, {'expired': False, 'start': 30, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 30, 'reset_pending': 'old', 'drop': False}), ({'now': 0, 'start': 10, 'width': 25, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 20}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 35, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 30, 'start': 30, 'width': 25, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 20}, {'expired': False, 'start': 30, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 25, 'reset_pending': None, 'drop': 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:
Throttle keeps an event in a window that has just ended; the returned lifecycle plan violates the stated transition contract.

Plan a fixed-window throttled observer: a window is [start,start+width); first event may emit on leading policy, latest suppressed event may emit on trailing policy at expiry. A new window starts at the arriving event time, not at the previous window start. Leading emission consumes the leading slot; a trailing-only window must keep its first event. A completed trailing flush resets its marker. A pending trailing payload is new only when its sequence is strictly later than the sequence already delivered on the leading edge. 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: expired = s['now']>=s['start']+s['width']; start = s['now'] if not s['open'] or s['now']>=s['start']+s['width'] else s['start']; leading_emit = s['leading'] and not s['used'] and s['incoming'] is not None; trailing_payload = s['incoming'] if s['trailing'] and s['incoming'] is not None else s['pending']; flush = s['trailing'] and s['pending'] is not None and s['open'] and s['now']>=s['start']+s['width']; used = s['used'] or (s['leading'] and s['incoming'] is not None); first_trailing = s['trailing'] and not s['leading'] and not s['open'] and s['incoming'] is not None; remaining = max(0,s['start']+s['width']-s['now']); reset_pending = s['pending'] if s['pending_sequence']>s['leading_sequence'] else None; drop = s['incoming'] is not None and s['used'] and not s['trailing']

split: open-access


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

N = 1
observations = []
def solve(s):
    return {
        'expired': s['now']>=s['start']+s['width'],
        'start': s['start'],
        'leading_emit': s['leading'] and not s['used'] and s['incoming'] is not None,
        'trailing_payload': s['incoming'] if s['trailing'] and s['incoming'] is not None else s['pending'],
        'flush': s['trailing'] and s['pending'] is not None and s['open'] and s['now']>=s['start']+s['width'],
        'used': s['used'] or (s['leading'] and s['incoming'] is not None),
        'first_trailing': s['trailing'] and not s['leading'] and not s['open'] and s['incoming'] is not None,
        'remaining': max(0,s['start']+s['width']-s['now']),
        'reset_pending': s['pending'] if s['pending_sequence']>s['leading_sequence'] else None,
        'drop': s['incoming'] is not None and s['used'] and not s['trailing'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'now': 6, 'start': 0, 'width': 2, 'open': False, 'leading': False, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 2, 'leading_sequence': 2}, {'expired': True, 'start': 6, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 2, 'width': 5, 'open': True, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 4, 'leading_sequence': 0}, {'expired': False, 'start': 2, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 1, 'reset_pending': 'old', 'drop': False}), ({'now': 2, 'start': 2, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 0, 'leading_sequence': 2}, {'expired': True, 'start': 2, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 2, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': 'old', 'drop': False}), ({'now': 2, 'start': 6, 'width': 2, 'open': True, 'leading': True, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 4}, {'expired': False, 'start': 6, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 6, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 6, 'width': 0, 'open': True, 'leading': False, 'trailing': True, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 2}, {'expired': True, 'start': 6, 'leading_emit': False, 'trailing_payload': 'old', 'flush': True, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 6, 'width': 5, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 4, 'leading_sequence': 4}, {'expired': False, 'start': 6, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 5, 'reset_pending': None, 'drop': False})], 2: [({'now': 12, 'start': 4, 'width': 4, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': True, 'start': 12, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 12, 'start': 12, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 4, 'leading_sequence': 8}, {'expired': True, 'start': 12, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 4, 'start': 0, 'width': 10, 'open': True, 'leading': True, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 4}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 6, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 12, 'width': 4, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': True, 'remaining': 16, 'reset_pending': None, 'drop': False}), ({'now': 4, 'start': 12, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': True, 'pending_sequence': 0, 'leading_sequence': 4}, {'expired': False, 'start': 4, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 8, 'reset_pending': None, 'drop': False}), ({'now': 4, 'start': 12, 'width': 10, 'open': False, 'leading': True, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': True, 'pending_sequence': 4, 'leading_sequence': 4}, {'expired': False, 'start': 4, 'leading_emit': True, 'trailing_payload': None, 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 18, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 12, 'start': 12, 'width': 10, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': False, 'start': 12, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 10, 'reset_pending': None, 'drop': False})], 3: [({'now': 18, 'start': 0, 'width': 6, 'open': False, 'leading': False, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 18, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 6, 'leading_sequence': 12}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 6, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 6, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 18, 'width': 6, 'open': True, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 12, 'leading_sequence': 6}, {'expired': False, 'start': 18, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 24, 'reset_pending': 'old', 'drop': False}), ({'now': 0, 'start': 18, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 0, 'leading_sequence': 12}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 18, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 6, 'width': 0, 'open': True, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 12, 'leading_sequence': 6}, {'expired': True, 'start': 6, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 18, 'start': 18, 'width': 15, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 12, 'leading_sequence': 12}, {'expired': False, 'start': 18, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 15, 'reset_pending': None, 'drop': False})], 4: [({'now': 24, 'start': 0, 'width': 8, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 24, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 0, 'width': 20, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': None, 'flushed': True, 'pending_sequence': 16, 'leading_sequence': 0}, {'expired': False, 'start': 8, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 12, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 8, 'width': 0, 'open': True, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 16, 'leading_sequence': 0}, {'expired': True, 'start': 8, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': 'old', 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 8, 'width': 8, 'open': True, 'leading': True, 'trailing': False, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 16, 'leading_sequence': 16}, {'expired': False, 'start': 8, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 8, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 0, 'width': 20, 'open': True, 'leading': True, 'trailing': True, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 8, 'leading_sequence': 16}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 12, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 24, 'start': 24, 'width': 20, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 16, 'leading_sequence': 16}, {'expired': False, 'start': 24, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 20, 'reset_pending': None, 'drop': False})], 5: [({'now': 30, 'start': 10, 'width': 10, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 20}, {'expired': True, 'start': 30, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 30, 'start': 30, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 10}, {'expired': True, 'start': 30, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 10, 'start': 0, 'width': 25, 'open': True, 'leading': False, 'trailing': False, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 20}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 15, 'reset_pending': None, 'drop': True}), ({'now': 0, 'start': 10, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': None, 'flushed': True, 'pending_sequence': 10, 'leading_sequence': 20}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 10, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 30, 'width': 0, 'open': True, 'leading': False, 'trailing': True, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 0}, {'expired': False, 'start': 30, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 30, 'reset_pending': 'old', 'drop': False}), ({'now': 0, 'start': 10, 'width': 25, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 20}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 35, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 30, 'start': 30, 'width': 25, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 20}, {'expired': False, 'start': 30, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 25, 'reset_pending': None, 'drop': 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 {
        'expired': s['now']>=s['start']+s['width'],
        'start': s['start']+s['width'] if s['now']>=s['start']+s['width'] else s['start'],
        'leading_emit': s['leading'] and not s['used'] and s['incoming'] is not None,
        'trailing_payload': s['incoming'] if s['trailing'] and s['incoming'] is not None else s['pending'],
        'flush': s['trailing'] and s['pending'] is not None and s['open'] and s['now']>=s['start']+s['width'],
        'used': s['used'] or (s['leading'] and s['incoming'] is not None),
        'first_trailing': s['trailing'] and not s['leading'] and not s['open'] and s['incoming'] is not None,
        'remaining': max(0,s['start']+s['width']-s['now']),
        'reset_pending': s['pending'] if s['pending_sequence']>s['leading_sequence'] else None,
        'drop': s['incoming'] is not None and s['used'] and not s['trailing'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'now': 6, 'start': 0, 'width': 2, 'open': False, 'leading': False, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 2, 'leading_sequence': 2}, {'expired': True, 'start': 6, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 2, 'width': 5, 'open': True, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 4, 'leading_sequence': 0}, {'expired': False, 'start': 2, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 1, 'reset_pending': 'old', 'drop': False}), ({'now': 2, 'start': 2, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 0, 'leading_sequence': 2}, {'expired': True, 'start': 2, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 2, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': 'old', 'drop': False}), ({'now': 2, 'start': 6, 'width': 2, 'open': True, 'leading': True, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 4}, {'expired': False, 'start': 6, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 6, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 6, 'width': 0, 'open': True, 'leading': False, 'trailing': True, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 2}, {'expired': True, 'start': 6, 'leading_emit': False, 'trailing_payload': 'old', 'flush': True, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 6, 'width': 5, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 4, 'leading_sequence': 4}, {'expired': False, 'start': 6, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 5, 'reset_pending': None, 'drop': False})], 2: [({'now': 12, 'start': 4, 'width': 4, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': True, 'start': 12, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 12, 'start': 12, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 4, 'leading_sequence': 8}, {'expired': True, 'start': 12, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 4, 'start': 0, 'width': 10, 'open': True, 'leading': True, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 4}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 6, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 12, 'width': 4, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': True, 'remaining': 16, 'reset_pending': None, 'drop': False}), ({'now': 4, 'start': 12, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': True, 'pending_sequence': 0, 'leading_sequence': 4}, {'expired': False, 'start': 4, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 8, 'reset_pending': None, 'drop': False}), ({'now': 4, 'start': 12, 'width': 10, 'open': False, 'leading': True, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': True, 'pending_sequence': 4, 'leading_sequence': 4}, {'expired': False, 'start': 4, 'leading_emit': True, 'trailing_payload': None, 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 18, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 12, 'start': 12, 'width': 10, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': False, 'start': 12, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 10, 'reset_pending': None, 'drop': False})], 3: [({'now': 18, 'start': 0, 'width': 6, 'open': False, 'leading': False, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 18, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 6, 'leading_sequence': 12}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 6, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 6, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 18, 'width': 6, 'open': True, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 12, 'leading_sequence': 6}, {'expired': False, 'start': 18, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 24, 'reset_pending': 'old', 'drop': False}), ({'now': 0, 'start': 18, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 0, 'leading_sequence': 12}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 18, 'reset_pending': None, 'drop': False}), ({'now': 6, 'start': 6, 'width': 0, 'open': True, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': None, 'flushed': False, 'pending_sequence': 12, 'leading_sequence': 6}, {'expired': True, 'start': 6, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 18, 'start': 18, 'width': 15, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 12, 'leading_sequence': 12}, {'expired': False, 'start': 18, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 15, 'reset_pending': None, 'drop': False})], 4: [({'now': 24, 'start': 0, 'width': 8, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 24, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 0, 'width': 20, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': None, 'flushed': True, 'pending_sequence': 16, 'leading_sequence': 0}, {'expired': False, 'start': 8, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 12, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 8, 'width': 0, 'open': True, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 16, 'leading_sequence': 0}, {'expired': True, 'start': 8, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': 'old', 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 8, 'leading_sequence': 8}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 8, 'width': 8, 'open': True, 'leading': True, 'trailing': False, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': False, 'pending_sequence': 16, 'leading_sequence': 16}, {'expired': False, 'start': 8, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 8, 'reset_pending': None, 'drop': False}), ({'now': 8, 'start': 0, 'width': 20, 'open': True, 'leading': True, 'trailing': True, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 8, 'leading_sequence': 16}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 12, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 24, 'start': 24, 'width': 20, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 16, 'leading_sequence': 16}, {'expired': False, 'start': 24, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 20, 'reset_pending': None, 'drop': False})], 5: [({'now': 30, 'start': 10, 'width': 10, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 20}, {'expired': True, 'start': 30, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': False, 'first_trailing': True, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 30, 'start': 30, 'width': 0, 'open': False, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 10}, {'expired': True, 'start': 30, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 10, 'start': 0, 'width': 25, 'open': True, 'leading': False, 'trailing': False, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 20}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 15, 'reset_pending': None, 'drop': True}), ({'now': 0, 'start': 10, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': True, 'incoming': None, 'pending': None, 'flushed': True, 'pending_sequence': 10, 'leading_sequence': 20}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 10, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 30, 'width': 0, 'open': True, 'leading': False, 'trailing': True, 'used': True, 'incoming': None, 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 0}, {'expired': False, 'start': 30, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 30, 'reset_pending': 'old', 'drop': False}), ({'now': 0, 'start': 10, 'width': 25, 'open': False, 'leading': False, 'trailing': True, 'used': False, 'incoming': None, 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 20}, {'expired': False, 'start': 0, 'leading_emit': False, 'trailing_payload': 'old', 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 35, 'reset_pending': None, 'drop': False}), ({'now': 0, 'start': 0, 'width': 0, 'open': False, 'leading': False, 'trailing': False, 'used': False, 'incoming': None, 'pending': None, 'flushed': False, 'pending_sequence': 0, 'leading_sequence': 0}, {'expired': True, 'start': 0, 'leading_emit': False, 'trailing_payload': None, 'flush': False, 'used': False, 'first_trailing': False, 'remaining': 0, 'reset_pending': None, 'drop': False}), ({'now': 30, 'start': 30, 'width': 25, 'open': True, 'leading': True, 'trailing': True, 'used': True, 'incoming': 'new', 'pending': 'old', 'flushed': True, 'pending_sequence': 20, 'leading_sequence': 20}, {'expired': False, 'start': 30, 'leading_emit': False, 'trailing_payload': 'new', 'flush': False, 'used': True, 'first_trailing': False, 'remaining': 25, 'reset_pending': None, 'drop': 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:
Throttle renewal reuses the old window origin; the returned lifecycle plan violates the stated transition contract.

Plan a fixed-window throttled observer: a window is [start,start+width); first event may emit on leading policy, latest suppressed event may emit on trailing policy at expiry. A new window starts at the arriving event time, not at the previous window start. Leading emission consumes the leading slot; a trailing-only window must keep its first event. A completed trailing flush resets its marker. A pending trailing payload is new only when its sequence is strictly later than the sequence already delivered on the leading edge. 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: expired = s['now']>=s['start']+s['width']; start = s['now'] if not s['open'] or s['now']>=s['start']+s['width'] else s['start']; leading_emit = s['leading'] and not s['used'] and s['incoming'] is not None; trailing_payload = s['incoming'] if s['trailing'] and s['incoming'] is not None else s['pending']; flush = s['trailing'] and s['pending'] is not None and s['open'] and s['now']>=s['start']+s['width']; used = s['used'] or (s['leading'] and s['incoming'] is not None); first_trailing = s['trailing'] and not s['leading'] and not s['open'] and s['incoming'] is not None; remaining = max(0,s['start']+s['width']-s['now']); reset_pending = s['pending'] if s['pending_sequence']>s['leading_sequence'] else None; drop = s['incoming'] is not None and s['used'] and not s['trailing']

split: open-access