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

N = 1
observations = []
def solve(s):
    return {
        'eligible': [r[0] for r in s['entries'] if r[3] and s['floor']<=r[1]<=s['ceiling']],
        'order': [r[0] for r in sorted(s['entries'],key=lambda r:(-r[1],r[2]))],
        'disabled': [],
        'take': [r[0] for r in s['entries'][:max(0,s['budget'])]],
        'defer': [r[0] for r in s['entries'][max(0,s['budget']):]],
        'above': [r[0] for r in s['entries'] if r[3] and r[1]>s['ceiling']],
        'below': [r[0] for r in s['entries'] if r[3] and r[1]<s['floor']],
        'tie_sequence': [[r[0],r[2]] for r in s['entries']],
        'budget_left': max(0,s['budget']-len(s['entries'])),
        'valid_window': s['floor']<=s['ceiling'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'entries': [['a', 3, 0, False], ['b', 1, 1, True], ['c', 4, 2, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 1, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', 2, 3, True], ['b', 2, 1, True], ['c', 1, 2, True]], 'floor': 3, 'ceiling': 3, 'budget': 1}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a'], 'defer': ['b', 'c'], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 3], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 3, 0, False], ['b', 1, 1, True], ['c', 4, 2, True]], 'floor': 3, 'ceiling': 3, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 3, 'ceiling': 5, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 3, 'ceiling': 5, 'budget': 3}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 1, 'valid_window': True})], 2: [({'entries': [['a', 6, 0, False], ['b', 1, 1, True], ['c', 8, 4, True]], 'floor': 6, 'ceiling': 1, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 6, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': True}), ({'entries': [['a', 4, 6, True], ['b', 4, 1, True], ['c', 1, 4, True]], 'floor': 1, 'ceiling': 6, 'budget': -1}, {'eligible': ['a', 'b', 'c'], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': [], 'tie_sequence': [['a', 6], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 1, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': False}), ({'entries': [], 'floor': -2, 'ceiling': 10, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 4, 6, True], ['b', 4, 1, True], ['c', 1, 4, True]], 'floor': 6, 'ceiling': 10, 'budget': -1}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 6], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 10, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': True})], 3: [({'entries': [['a', 9, 0, False], ['b', 1, 1, True], ['c', 12, 6, True]], 'floor': 9, 'ceiling': 1, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 9, 'ceiling': 9, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 6, 9, True], ['b', 6, 1, True], ['c', 1, 6, True]], 'floor': 1, 'ceiling': 15, 'budget': 1}, {'eligible': ['a', 'b', 'c'], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a'], 'defer': ['b', 'c'], 'above': [], 'below': [], 'tie_sequence': [['a', 9], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 1, 'budget': 1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 1, 'valid_window': True}), ({'entries': [['a', 9, 0, False], ['b', 1, 1, True], ['c', 12, 6, True]], 'floor': 9, 'ceiling': 9, 'budget': 1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': ['a'], 'defer': ['b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 9, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 9, 'ceiling': 15, 'budget': 9}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 7, 'valid_window': True})], 4: [({'entries': [['a', 12, 0, False], ['b', 1, 1, True], ['c', 16, 8, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 8]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 12, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', 8, 12, True], ['b', 8, 1, True], ['c', 1, 8, True]], 'floor': 12, 'ceiling': 12, 'budget': 12}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a', 'b', 'c'], 'defer': [], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 12], ['b', 1], ['c', 8]], 'budget_left': 9, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 1, 'budget': 1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 12, 0, False], ['b', 1, 1, True], ['c', 16, 8, True]], 'floor': 12, 'ceiling': 20, 'budget': -1}, {'eligible': ['c'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 8]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 20, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 12, 'ceiling': 20, 'budget': 12}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 10, 'valid_window': True})], 5: [({'entries': [['a', 15, 0, False], ['b', 1, 1, True], ['c', 20, 10, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 10]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 1, 'ceiling': 0, 'budget': 15}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 13, 'valid_window': False}), ({'entries': [['a', 10, 15, True], ['b', 10, 1, True], ['c', 1, 10, True]], 'floor': 15, 'ceiling': 25, 'budget': 15}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a', 'b', 'c'], 'defer': [], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 15], ['b', 1], ['c', 10]], 'budget_left': 12, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 10, 'budget': 15}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 15, 'valid_window': True}), ({'entries': [['a', 15, 0, False], ['b', 1, 1, True], ['c', 20, 10, True]], 'floor': 1, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': ['a'], 'defer': ['b', 'c'], 'above': ['b', 'c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 10]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 15, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 15, 'ceiling': 25, 'budget': 15}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 13, 'valid_window': True})]}
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 {
        'eligible': [r[0] for r in s['entries'] if r[3] and s['floor']<=r[1]<=s['ceiling']],
        'order': [r[0] for r in sorted(s['entries'],key=lambda r:(-r[1],r[2]))],
        'disabled': [r[0] for r in s['entries'] if not r[3] and r[1]>=s['floor']],
        'take': [r[0] for r in s['entries'][:max(0,s['budget'])]],
        'defer': [r[0] for r in s['entries'][max(0,s['budget']):]],
        'above': [r[0] for r in s['entries'] if r[3] and r[1]>s['ceiling']],
        'below': [r[0] for r in s['entries'] if r[3] and r[1]<s['floor']],
        'tie_sequence': [[r[0],r[2]] for r in s['entries']],
        'budget_left': max(0,s['budget']-len(s['entries'])),
        'valid_window': s['floor']<=s['ceiling'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'entries': [['a', 3, 0, False], ['b', 1, 1, True], ['c', 4, 2, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 1, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', 2, 3, True], ['b', 2, 1, True], ['c', 1, 2, True]], 'floor': 3, 'ceiling': 3, 'budget': 1}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a'], 'defer': ['b', 'c'], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 3], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 3, 0, False], ['b', 1, 1, True], ['c', 4, 2, True]], 'floor': 3, 'ceiling': 3, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 3, 'ceiling': 5, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 3, 'ceiling': 5, 'budget': 3}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 1, 'valid_window': True})], 2: [({'entries': [['a', 6, 0, False], ['b', 1, 1, True], ['c', 8, 4, True]], 'floor': 6, 'ceiling': 1, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 6, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': True}), ({'entries': [['a', 4, 6, True], ['b', 4, 1, True], ['c', 1, 4, True]], 'floor': 1, 'ceiling': 6, 'budget': -1}, {'eligible': ['a', 'b', 'c'], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': [], 'tie_sequence': [['a', 6], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 1, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': False}), ({'entries': [], 'floor': -2, 'ceiling': 10, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 4, 6, True], ['b', 4, 1, True], ['c', 1, 4, True]], 'floor': 6, 'ceiling': 10, 'budget': -1}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 6], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 10, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': True})], 3: [({'entries': [['a', 9, 0, False], ['b', 1, 1, True], ['c', 12, 6, True]], 'floor': 9, 'ceiling': 1, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 9, 'ceiling': 9, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 6, 9, True], ['b', 6, 1, True], ['c', 1, 6, True]], 'floor': 1, 'ceiling': 15, 'budget': 1}, {'eligible': ['a', 'b', 'c'], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a'], 'defer': ['b', 'c'], 'above': [], 'below': [], 'tie_sequence': [['a', 9], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 1, 'budget': 1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 1, 'valid_window': True}), ({'entries': [['a', 9, 0, False], ['b', 1, 1, True], ['c', 12, 6, True]], 'floor': 9, 'ceiling': 9, 'budget': 1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': ['a'], 'defer': ['b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 9, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 9, 'ceiling': 15, 'budget': 9}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 7, 'valid_window': True})], 4: [({'entries': [['a', 12, 0, False], ['b', 1, 1, True], ['c', 16, 8, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 8]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 12, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', 8, 12, True], ['b', 8, 1, True], ['c', 1, 8, True]], 'floor': 12, 'ceiling': 12, 'budget': 12}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a', 'b', 'c'], 'defer': [], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 12], ['b', 1], ['c', 8]], 'budget_left': 9, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 1, 'budget': 1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 12, 0, False], ['b', 1, 1, True], ['c', 16, 8, True]], 'floor': 12, 'ceiling': 20, 'budget': -1}, {'eligible': ['c'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 8]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 20, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 12, 'ceiling': 20, 'budget': 12}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 10, 'valid_window': True})], 5: [({'entries': [['a', 15, 0, False], ['b', 1, 1, True], ['c', 20, 10, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 10]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 1, 'ceiling': 0, 'budget': 15}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 13, 'valid_window': False}), ({'entries': [['a', 10, 15, True], ['b', 10, 1, True], ['c', 1, 10, True]], 'floor': 15, 'ceiling': 25, 'budget': 15}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a', 'b', 'c'], 'defer': [], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 15], ['b', 1], ['c', 10]], 'budget_left': 12, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 10, 'budget': 15}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 15, 'valid_window': True}), ({'entries': [['a', 15, 0, False], ['b', 1, 1, True], ['c', 20, 10, True]], 'floor': 1, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': ['a'], 'defer': ['b', 'c'], 'above': ['b', 'c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 10]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 15, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 15, 'ceiling': 25, 'budget': 15}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 13, 'valid_window': True})]}
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:
Disabled listener records disappear from registry retention; the returned lifecycle plan violates the stated transition contract.

Build independent priority-dispatch projections from [id,priority,sequence,enabled] records. Eligibility applies inclusive floor and ceiling to enabled entries. Order sorts all stored entries by descending priority then ascending registration sequence. Separately, take/defer project a nonnegative budget split of raw storage order. Disabled entries remain stored. Above/below list enabled entries strictly outside bounds. Budget-left is clamped; an equal floor/ceiling is a valid window. 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: eligible = [r[0] for r in s['entries'] if r[3] and s['floor']<=r[1]<=s['ceiling']]; order = [r[0] for r in sorted(s['entries'],key=lambda r:(-r[1],r[2]))]; disabled = [r[0] for r in s['entries'] if not r[3]]; take = [r[0] for r in s['entries'][:max(0,s['budget'])]]; defer = [r[0] for r in s['entries'][max(0,s['budget']):]]; above = [r[0] for r in s['entries'] if r[3] and r[1]>s['ceiling']]; below = [r[0] for r in s['entries'] if r[3] and r[1]<s['floor']]; tie_sequence = [[r[0],r[2]] for r in s['entries']]; budget_left = max(0,s['budget']-len(s['entries'])); valid_window = s['floor']<=s['ceiling']

split: open-access


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

N = 1
observations = []
def solve(s):
    return {
        'eligible': [r[0] for r in s['entries'] if r[3] and s['floor']<=r[1]<=s['ceiling']],
        'order': [r[0] for r in sorted(s['entries'],key=lambda r:(-r[1],r[2]))],
        'disabled': [r[0] for r in s['entries'] if not r[3]],
        'take': [r[0] for r in s['entries'][:s['budget']]],
        'defer': [r[0] for r in s['entries'][max(0,s['budget']):]],
        'above': [r[0] for r in s['entries'] if r[3] and r[1]>s['ceiling']],
        'below': [r[0] for r in s['entries'] if r[3] and r[1]<s['floor']],
        'tie_sequence': [[r[0],r[2]] for r in s['entries']],
        'budget_left': max(0,s['budget']-len(s['entries'])),
        'valid_window': s['floor']<=s['ceiling'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'entries': [['a', 3, 0, False], ['b', 1, 1, True], ['c', 4, 2, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 1, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', 2, 3, True], ['b', 2, 1, True], ['c', 1, 2, True]], 'floor': 3, 'ceiling': 3, 'budget': 1}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a'], 'defer': ['b', 'c'], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 3], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 3, 0, False], ['b', 1, 1, True], ['c', 4, 2, True]], 'floor': 3, 'ceiling': 3, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 3, 'ceiling': 5, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 3, 'ceiling': 5, 'budget': 3}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 1, 'valid_window': True})], 2: [({'entries': [['a', 6, 0, False], ['b', 1, 1, True], ['c', 8, 4, True]], 'floor': 6, 'ceiling': 1, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 6, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': True}), ({'entries': [['a', 4, 6, True], ['b', 4, 1, True], ['c', 1, 4, True]], 'floor': 1, 'ceiling': 6, 'budget': -1}, {'eligible': ['a', 'b', 'c'], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': [], 'tie_sequence': [['a', 6], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 1, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': False}), ({'entries': [], 'floor': -2, 'ceiling': 10, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 4, 6, True], ['b', 4, 1, True], ['c', 1, 4, True]], 'floor': 6, 'ceiling': 10, 'budget': -1}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 6], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 10, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': True})], 3: [({'entries': [['a', 9, 0, False], ['b', 1, 1, True], ['c', 12, 6, True]], 'floor': 9, 'ceiling': 1, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 9, 'ceiling': 9, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 6, 9, True], ['b', 6, 1, True], ['c', 1, 6, True]], 'floor': 1, 'ceiling': 15, 'budget': 1}, {'eligible': ['a', 'b', 'c'], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a'], 'defer': ['b', 'c'], 'above': [], 'below': [], 'tie_sequence': [['a', 9], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 1, 'budget': 1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 1, 'valid_window': True}), ({'entries': [['a', 9, 0, False], ['b', 1, 1, True], ['c', 12, 6, True]], 'floor': 9, 'ceiling': 9, 'budget': 1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': ['a'], 'defer': ['b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 9, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 9, 'ceiling': 15, 'budget': 9}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 7, 'valid_window': True})], 4: [({'entries': [['a', 12, 0, False], ['b', 1, 1, True], ['c', 16, 8, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 8]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 12, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', 8, 12, True], ['b', 8, 1, True], ['c', 1, 8, True]], 'floor': 12, 'ceiling': 12, 'budget': 12}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a', 'b', 'c'], 'defer': [], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 12], ['b', 1], ['c', 8]], 'budget_left': 9, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 1, 'budget': 1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 12, 0, False], ['b', 1, 1, True], ['c', 16, 8, True]], 'floor': 12, 'ceiling': 20, 'budget': -1}, {'eligible': ['c'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 8]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 20, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 12, 'ceiling': 20, 'budget': 12}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 10, 'valid_window': True})], 5: [({'entries': [['a', 15, 0, False], ['b', 1, 1, True], ['c', 20, 10, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 10]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 1, 'ceiling': 0, 'budget': 15}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 13, 'valid_window': False}), ({'entries': [['a', 10, 15, True], ['b', 10, 1, True], ['c', 1, 10, True]], 'floor': 15, 'ceiling': 25, 'budget': 15}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a', 'b', 'c'], 'defer': [], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 15], ['b', 1], ['c', 10]], 'budget_left': 12, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 10, 'budget': 15}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 15, 'valid_window': True}), ({'entries': [['a', 15, 0, False], ['b', 1, 1, True], ['c', 20, 10, True]], 'floor': 1, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': ['a'], 'defer': ['b', 'c'], 'above': ['b', 'c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 10]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 15, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 15, 'ceiling': 25, 'budget': 15}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 13, 'valid_window': True})]}
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 {
        'eligible': [r[0] for r in s['entries'] if r[3] and s['floor']<=r[1]<=s['ceiling']],
        'order': [r[0] for r in sorted(s['entries'],key=lambda r:(-r[1],r[2]))],
        'disabled': [r[0] for r in s['entries'] if not r[3]],
        'take': [r[0] for r in s['entries'][:max(1,s['budget'])]],
        'defer': [r[0] for r in s['entries'][max(0,s['budget']):]],
        'above': [r[0] for r in s['entries'] if r[3] and r[1]>s['ceiling']],
        'below': [r[0] for r in s['entries'] if r[3] and r[1]<s['floor']],
        'tie_sequence': [[r[0],r[2]] for r in s['entries']],
        'budget_left': max(0,s['budget']-len(s['entries'])),
        'valid_window': s['floor']<=s['ceiling'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'entries': [['a', 3, 0, False], ['b', 1, 1, True], ['c', 4, 2, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 1, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', 2, 3, True], ['b', 2, 1, True], ['c', 1, 2, True]], 'floor': 3, 'ceiling': 3, 'budget': 1}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a'], 'defer': ['b', 'c'], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 3], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 3, 0, False], ['b', 1, 1, True], ['c', 4, 2, True]], 'floor': 3, 'ceiling': 3, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 3, 'ceiling': 5, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 3, 'ceiling': 5, 'budget': 3}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 1, 'valid_window': True})], 2: [({'entries': [['a', 6, 0, False], ['b', 1, 1, True], ['c', 8, 4, True]], 'floor': 6, 'ceiling': 1, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 6, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': True}), ({'entries': [['a', 4, 6, True], ['b', 4, 1, True], ['c', 1, 4, True]], 'floor': 1, 'ceiling': 6, 'budget': -1}, {'eligible': ['a', 'b', 'c'], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': [], 'tie_sequence': [['a', 6], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 1, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': False}), ({'entries': [], 'floor': -2, 'ceiling': 10, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 4, 6, True], ['b', 4, 1, True], ['c', 1, 4, True]], 'floor': 6, 'ceiling': 10, 'budget': -1}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 6], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 10, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': True})], 3: [({'entries': [['a', 9, 0, False], ['b', 1, 1, True], ['c', 12, 6, True]], 'floor': 9, 'ceiling': 1, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 9, 'ceiling': 9, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 6, 9, True], ['b', 6, 1, True], ['c', 1, 6, True]], 'floor': 1, 'ceiling': 15, 'budget': 1}, {'eligible': ['a', 'b', 'c'], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a'], 'defer': ['b', 'c'], 'above': [], 'below': [], 'tie_sequence': [['a', 9], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 1, 'budget': 1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 1, 'valid_window': True}), ({'entries': [['a', 9, 0, False], ['b', 1, 1, True], ['c', 12, 6, True]], 'floor': 9, 'ceiling': 9, 'budget': 1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': ['a'], 'defer': ['b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 9, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 9, 'ceiling': 15, 'budget': 9}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 7, 'valid_window': True})], 4: [({'entries': [['a', 12, 0, False], ['b', 1, 1, True], ['c', 16, 8, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 8]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 12, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', 8, 12, True], ['b', 8, 1, True], ['c', 1, 8, True]], 'floor': 12, 'ceiling': 12, 'budget': 12}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a', 'b', 'c'], 'defer': [], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 12], ['b', 1], ['c', 8]], 'budget_left': 9, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 1, 'budget': 1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 12, 0, False], ['b', 1, 1, True], ['c', 16, 8, True]], 'floor': 12, 'ceiling': 20, 'budget': -1}, {'eligible': ['c'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 8]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 20, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 12, 'ceiling': 20, 'budget': 12}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 10, 'valid_window': True})], 5: [({'entries': [['a', 15, 0, False], ['b', 1, 1, True], ['c', 20, 10, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 10]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 1, 'ceiling': 0, 'budget': 15}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 13, 'valid_window': False}), ({'entries': [['a', 10, 15, True], ['b', 10, 1, True], ['c', 1, 10, True]], 'floor': 15, 'ceiling': 25, 'budget': 15}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a', 'b', 'c'], 'defer': [], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 15], ['b', 1], ['c', 10]], 'budget_left': 12, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 10, 'budget': 15}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 15, 'valid_window': True}), ({'entries': [['a', 15, 0, False], ['b', 1, 1, True], ['c', 20, 10, True]], 'floor': 1, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': ['a'], 'defer': ['b', 'c'], 'above': ['b', 'c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 10]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 15, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 15, 'ceiling': 25, 'budget': 15}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 13, 'valid_window': True})]}
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:
Negative callback budget dispatches all but the last listener; the returned lifecycle plan violates the stated transition contract.

Build independent priority-dispatch projections from [id,priority,sequence,enabled] records. Eligibility applies inclusive floor and ceiling to enabled entries. Order sorts all stored entries by descending priority then ascending registration sequence. Separately, take/defer project a nonnegative budget split of raw storage order. Disabled entries remain stored. Above/below list enabled entries strictly outside bounds. Budget-left is clamped; an equal floor/ceiling is a valid window. 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: eligible = [r[0] for r in s['entries'] if r[3] and s['floor']<=r[1]<=s['ceiling']]; order = [r[0] for r in sorted(s['entries'],key=lambda r:(-r[1],r[2]))]; disabled = [r[0] for r in s['entries'] if not r[3]]; take = [r[0] for r in s['entries'][:max(0,s['budget'])]]; defer = [r[0] for r in s['entries'][max(0,s['budget']):]]; above = [r[0] for r in s['entries'] if r[3] and r[1]>s['ceiling']]; below = [r[0] for r in s['entries'] if r[3] and r[1]<s['floor']]; tie_sequence = [[r[0],r[2]] for r in s['entries']]; budget_left = max(0,s['budget']-len(s['entries'])); valid_window = s['floor']<=s['ceiling']

split: open-access


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

N = 1
observations = []
def solve(s):
    return {
        'eligible': [r[0] for r in s['entries'] if r[3] and s['floor']<=r[1]<=s['ceiling']],
        'order': [r[0] for r in sorted(s['entries'],key=lambda r:(-r[1],r[2]))],
        'disabled': [r[0] for r in s['entries'] if not r[3]],
        'take': [r[0] for r in s['entries'][:max(0,s['budget'])]],
        'defer': [r[0] for r in s['entries'][max(0,s['budget'])+1:]],
        'above': [r[0] for r in s['entries'] if r[3] and r[1]>s['ceiling']],
        'below': [r[0] for r in s['entries'] if r[3] and r[1]<s['floor']],
        'tie_sequence': [[r[0],r[2]] for r in s['entries']],
        'budget_left': max(0,s['budget']-len(s['entries'])),
        'valid_window': s['floor']<=s['ceiling'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'entries': [['a', 3, 0, False], ['b', 1, 1, True], ['c', 4, 2, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 1, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', 2, 3, True], ['b', 2, 1, True], ['c', 1, 2, True]], 'floor': 3, 'ceiling': 3, 'budget': 1}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a'], 'defer': ['b', 'c'], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 3], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 3, 0, False], ['b', 1, 1, True], ['c', 4, 2, True]], 'floor': 3, 'ceiling': 3, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 3, 'ceiling': 5, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 3, 'ceiling': 5, 'budget': 3}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 1, 'valid_window': True})], 2: [({'entries': [['a', 6, 0, False], ['b', 1, 1, True], ['c', 8, 4, True]], 'floor': 6, 'ceiling': 1, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 6, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': True}), ({'entries': [['a', 4, 6, True], ['b', 4, 1, True], ['c', 1, 4, True]], 'floor': 1, 'ceiling': 6, 'budget': -1}, {'eligible': ['a', 'b', 'c'], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': [], 'tie_sequence': [['a', 6], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 1, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': False}), ({'entries': [], 'floor': -2, 'ceiling': 10, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 4, 6, True], ['b', 4, 1, True], ['c', 1, 4, True]], 'floor': 6, 'ceiling': 10, 'budget': -1}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 6], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 10, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': True})], 3: [({'entries': [['a', 9, 0, False], ['b', 1, 1, True], ['c', 12, 6, True]], 'floor': 9, 'ceiling': 1, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 9, 'ceiling': 9, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 6, 9, True], ['b', 6, 1, True], ['c', 1, 6, True]], 'floor': 1, 'ceiling': 15, 'budget': 1}, {'eligible': ['a', 'b', 'c'], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a'], 'defer': ['b', 'c'], 'above': [], 'below': [], 'tie_sequence': [['a', 9], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 1, 'budget': 1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 1, 'valid_window': True}), ({'entries': [['a', 9, 0, False], ['b', 1, 1, True], ['c', 12, 6, True]], 'floor': 9, 'ceiling': 9, 'budget': 1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': ['a'], 'defer': ['b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 9, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 9, 'ceiling': 15, 'budget': 9}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 7, 'valid_window': True})], 4: [({'entries': [['a', 12, 0, False], ['b', 1, 1, True], ['c', 16, 8, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 8]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 12, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', 8, 12, True], ['b', 8, 1, True], ['c', 1, 8, True]], 'floor': 12, 'ceiling': 12, 'budget': 12}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a', 'b', 'c'], 'defer': [], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 12], ['b', 1], ['c', 8]], 'budget_left': 9, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 1, 'budget': 1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 12, 0, False], ['b', 1, 1, True], ['c', 16, 8, True]], 'floor': 12, 'ceiling': 20, 'budget': -1}, {'eligible': ['c'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 8]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 20, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 12, 'ceiling': 20, 'budget': 12}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 10, 'valid_window': True})], 5: [({'entries': [['a', 15, 0, False], ['b', 1, 1, True], ['c', 20, 10, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 10]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 1, 'ceiling': 0, 'budget': 15}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 13, 'valid_window': False}), ({'entries': [['a', 10, 15, True], ['b', 10, 1, True], ['c', 1, 10, True]], 'floor': 15, 'ceiling': 25, 'budget': 15}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a', 'b', 'c'], 'defer': [], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 15], ['b', 1], ['c', 10]], 'budget_left': 12, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 10, 'budget': 15}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 15, 'valid_window': True}), ({'entries': [['a', 15, 0, False], ['b', 1, 1, True], ['c', 20, 10, True]], 'floor': 1, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': ['a'], 'defer': ['b', 'c'], 'above': ['b', 'c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 10]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 15, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 15, 'ceiling': 25, 'budget': 15}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 13, 'valid_window': True})]}
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 {
        'eligible': [r[0] for r in s['entries'] if r[3] and s['floor']<=r[1]<=s['ceiling']],
        'order': [r[0] for r in sorted(s['entries'],key=lambda r:(-r[1],r[2]))],
        'disabled': [r[0] for r in s['entries'] if not r[3]],
        'take': [r[0] for r in s['entries'][:max(0,s['budget'])]],
        'defer': [r[0] for r in s['entries'][s['budget']:]],
        'above': [r[0] for r in s['entries'] if r[3] and r[1]>s['ceiling']],
        'below': [r[0] for r in s['entries'] if r[3] and r[1]<s['floor']],
        'tie_sequence': [[r[0],r[2]] for r in s['entries']],
        'budget_left': max(0,s['budget']-len(s['entries'])),
        'valid_window': s['floor']<=s['ceiling'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'entries': [['a', 3, 0, False], ['b', 1, 1, True], ['c', 4, 2, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 1, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', 2, 3, True], ['b', 2, 1, True], ['c', 1, 2, True]], 'floor': 3, 'ceiling': 3, 'budget': 1}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a'], 'defer': ['b', 'c'], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 3], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 3, 0, False], ['b', 1, 1, True], ['c', 4, 2, True]], 'floor': 3, 'ceiling': 3, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 2]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 3, 'ceiling': 5, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 3, 'ceiling': 5, 'budget': 3}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 1, 'valid_window': True})], 2: [({'entries': [['a', 6, 0, False], ['b', 1, 1, True], ['c', 8, 4, True]], 'floor': 6, 'ceiling': 1, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 6, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': True}), ({'entries': [['a', 4, 6, True], ['b', 4, 1, True], ['c', 1, 4, True]], 'floor': 1, 'ceiling': 6, 'budget': -1}, {'eligible': ['a', 'b', 'c'], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': [], 'tie_sequence': [['a', 6], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 1, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': False}), ({'entries': [], 'floor': -2, 'ceiling': 10, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 4, 6, True], ['b', 4, 1, True], ['c', 1, 4, True]], 'floor': 6, 'ceiling': 10, 'budget': -1}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 6], ['b', 1], ['c', 4]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 6, 'ceiling': 10, 'budget': 6}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 4, 'valid_window': True})], 3: [({'entries': [['a', 9, 0, False], ['b', 1, 1, True], ['c', 12, 6, True]], 'floor': 9, 'ceiling': 1, 'budget': -1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 9, 'ceiling': 9, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 6, 9, True], ['b', 6, 1, True], ['c', 1, 6, True]], 'floor': 1, 'ceiling': 15, 'budget': 1}, {'eligible': ['a', 'b', 'c'], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a'], 'defer': ['b', 'c'], 'above': [], 'below': [], 'tie_sequence': [['a', 9], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 1, 'budget': 1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 1, 'valid_window': True}), ({'entries': [['a', 9, 0, False], ['b', 1, 1, True], ['c', 12, 6, True]], 'floor': 9, 'ceiling': 9, 'budget': 1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': ['a'], 'defer': ['b', 'c'], 'above': ['c'], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 6]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 9, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 9, 'ceiling': 15, 'budget': 9}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 7, 'valid_window': True})], 4: [({'entries': [['a', 12, 0, False], ['b', 1, 1, True], ['c', 16, 8, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 8]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 12, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', 8, 12, True], ['b', 8, 1, True], ['c', 1, 8, True]], 'floor': 12, 'ceiling': 12, 'budget': 12}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a', 'b', 'c'], 'defer': [], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 12], ['b', 1], ['c', 8]], 'budget_left': 9, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 1, 'budget': 1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a'], 'defer': ['b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', 12, 0, False], ['b', 1, 1, True], ['c', 16, 8, True]], 'floor': 12, 'ceiling': 20, 'budget': -1}, {'eligible': ['c'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': [], 'below': ['b'], 'tie_sequence': [['a', 0], ['b', 1], ['c', 8]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 20, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 12, 'ceiling': 20, 'budget': 12}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 10, 'valid_window': True})], 5: [({'entries': [['a', 15, 0, False], ['b', 1, 1, True], ['c', 20, 10, True]], 'floor': 1, 'ceiling': 1, 'budget': -1}, {'eligible': ['b'], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': [], 'defer': ['a', 'b', 'c'], 'above': ['c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 10]], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 1, 'ceiling': 0, 'budget': 15}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 13, 'valid_window': False}), ({'entries': [['a', 10, 15, True], ['b', 10, 1, True], ['c', 1, 10, True]], 'floor': 15, 'ceiling': 25, 'budget': 15}, {'eligible': [], 'order': ['b', 'a', 'c'], 'disabled': [], 'take': ['a', 'b', 'c'], 'defer': [], 'above': [], 'below': ['a', 'b', 'c'], 'tie_sequence': [['a', 15], ['b', 1], ['c', 10]], 'budget_left': 12, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 10, 'budget': 15}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 15, 'valid_window': True}), ({'entries': [['a', 15, 0, False], ['b', 1, 1, True], ['c', 20, 10, True]], 'floor': 1, 'ceiling': 0, 'budget': 1}, {'eligible': [], 'order': ['c', 'a', 'b'], 'disabled': ['a'], 'take': ['a'], 'defer': ['b', 'c'], 'above': ['b', 'c'], 'below': [], 'tie_sequence': [['a', 0], ['b', 1], ['c', 10]], 'budget_left': 0, 'valid_window': False}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': -2, 'ceiling': 15, 'budget': -1}, {'eligible': ['a'], 'order': ['b', 'a'], 'disabled': ['b'], 'take': [], 'defer': ['a', 'b'], 'above': [], 'below': [], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 0, 'valid_window': True}), ({'entries': [], 'floor': -2, 'ceiling': 0, 'budget': -1}, {'eligible': [], 'order': [], 'disabled': [], 'take': [], 'defer': [], 'above': [], 'below': [], 'tie_sequence': [], 'budget_left': 0, 'valid_window': True}), ({'entries': [['a', -1, 0, True], ['b', 0, 1, False]], 'floor': 15, 'ceiling': 25, 'budget': 15}, {'eligible': [], 'order': ['b', 'a'], 'disabled': ['b'], 'take': ['a', 'b'], 'defer': [], 'above': [], 'below': ['a'], 'tie_sequence': [['a', 0], ['b', 1]], 'budget_left': 13, 'valid_window': True})]}
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:
Dispatch budget loses the first deferred listener; the returned lifecycle plan violates the stated transition contract.

Build independent priority-dispatch projections from [id,priority,sequence,enabled] records. Eligibility applies inclusive floor and ceiling to enabled entries. Order sorts all stored entries by descending priority then ascending registration sequence. Separately, take/defer project a nonnegative budget split of raw storage order. Disabled entries remain stored. Above/below list enabled entries strictly outside bounds. Budget-left is clamped; an equal floor/ceiling is a valid window. 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: eligible = [r[0] for r in s['entries'] if r[3] and s['floor']<=r[1]<=s['ceiling']]; order = [r[0] for r in sorted(s['entries'],key=lambda r:(-r[1],r[2]))]; disabled = [r[0] for r in s['entries'] if not r[3]]; take = [r[0] for r in s['entries'][:max(0,s['budget'])]]; defer = [r[0] for r in s['entries'][max(0,s['budget']):]]; above = [r[0] for r in s['entries'] if r[3] and r[1]>s['ceiling']]; below = [r[0] for r in s['entries'] if r[3] and r[1]<s['floor']]; tie_sequence = [[r[0],r[2]] for r in s['entries']]; budget_left = max(0,s['budget']-len(s['entries'])); valid_window = s['floor']<=s['ceiling']

split: open-access