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

N = 1
observations = []
def solve(s):
    return {
        'fields': s['dirty']+([s['incoming']] if s['incoming'] is not None else []),
        'schedule': bool(s['dirty'] or s['incoming'] is not None or s['full']) and not s['scheduled'] and not s['disposed'],
        'flush_fields': list(dict.fromkeys(s['dirty'])) if s['flush'] and not s['disposed'] and not s['full'] else [],
        'next_batch': list(dict.fromkeys(s['during'])) if s['flush'] and not s['disposed'] else [],
        'full': s['full'] and s['flush'] and not s['disposed'],
        'version': s['version']+int(s['flush'] and bool(s['dirty'] or s['full']) and not s['disposed']),
        'scheduled_after': bool(s['during']) if s['flush'] else s['scheduled'],
        'stale': s['delivered']<s['version'],
        'reentrant': s['flush'] and s['running'],
        'retained': [] if s['disposed'] else list(dict.fromkeys(s['dirty'])),
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 2, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': ['a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': ['a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': False, 'during': ['late'], 'full': True, 'disposed': True, 'version': 2, 'delivered': 1, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': False, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': False, 'disposed': False, 'version': 2, 'delivered': 0, 'running': False}, {'fields': ['a', 'b', 'c'], 'schedule': True, 'flush_fields': ['a', 'b'], 'next_batch': ['late'], 'full': False, 'version': 3, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': ['a', 'b']}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': [], 'full': True, 'disposed': True, 'version': 2, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': False, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 2, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 2: [({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'a', 'scheduled': True, 'flush': False, 'during': [], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': ['a', 'b'], 'next_batch': ['late'], 'full': False, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': ['a', 'b']}), ({'dirty': ['c', 'a'], 'incoming': None, 'scheduled': False, 'flush': False, 'during': ['late'], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a'], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': False}, {'fields': ['a', 'c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 3: [({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': []}), ({'dirty': ['a'], 'incoming': 'a', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': ['a']}), ({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a'], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['a', 'c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': ['a']}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': True, 'during': [], 'full': False, 'disposed': False, 'version': 6, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 6, 'scheduled_after': False, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 6, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 6, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 6, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 6, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 4: [({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': False, 'during': ['late'], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': [], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['a', 'b', 'c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': [], 'full': False, 'disposed': True, 'version': 8, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 8, 'scheduled_after': False, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': False, 'version': 8, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 8, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 8, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 8, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 5: [({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 10, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 11, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': False, 'during': [], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': [], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': [], 'full': False, 'disposed': False, 'version': 10, 'delivered': 1, 'running': False}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': ['a', 'b'], 'next_batch': [], 'full': False, 'version': 11, 'scheduled_after': False, 'stale': True, 'reentrant': False, 'retained': ['a', 'b']}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 10, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 10, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})]}
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 {
        'fields': sorted(set(s['dirty']+([s['incoming']] if s['incoming'] is not None else []))),
        'schedule': bool(s['dirty'] or s['incoming'] is not None or s['full']) and not s['scheduled'] and not s['disposed'],
        'flush_fields': list(dict.fromkeys(s['dirty'])) if s['flush'] and not s['disposed'] and not s['full'] else [],
        'next_batch': list(dict.fromkeys(s['during'])) if s['flush'] and not s['disposed'] else [],
        'full': s['full'] and s['flush'] and not s['disposed'],
        'version': s['version']+int(s['flush'] and bool(s['dirty'] or s['full']) and not s['disposed']),
        'scheduled_after': bool(s['during']) if s['flush'] else s['scheduled'],
        'stale': s['delivered']<s['version'],
        'reentrant': s['flush'] and s['running'],
        'retained': [] if s['disposed'] else list(dict.fromkeys(s['dirty'])),
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 2, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': ['a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': ['a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': False, 'during': ['late'], 'full': True, 'disposed': True, 'version': 2, 'delivered': 1, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': False, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': False, 'disposed': False, 'version': 2, 'delivered': 0, 'running': False}, {'fields': ['a', 'b', 'c'], 'schedule': True, 'flush_fields': ['a', 'b'], 'next_batch': ['late'], 'full': False, 'version': 3, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': ['a', 'b']}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': [], 'full': True, 'disposed': True, 'version': 2, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': False, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 2, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 2: [({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'a', 'scheduled': True, 'flush': False, 'during': [], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': ['a', 'b'], 'next_batch': ['late'], 'full': False, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': ['a', 'b']}), ({'dirty': ['c', 'a'], 'incoming': None, 'scheduled': False, 'flush': False, 'during': ['late'], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a'], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': False}, {'fields': ['a', 'c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 3: [({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': []}), ({'dirty': ['a'], 'incoming': 'a', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': ['a']}), ({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a'], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['a', 'c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': ['a']}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': True, 'during': [], 'full': False, 'disposed': False, 'version': 6, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 6, 'scheduled_after': False, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 6, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 6, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 6, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 6, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 4: [({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': False, 'during': ['late'], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': [], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['a', 'b', 'c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': [], 'full': False, 'disposed': True, 'version': 8, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 8, 'scheduled_after': False, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': False, 'version': 8, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 8, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 8, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 8, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 5: [({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 10, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 11, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': False, 'during': [], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': [], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': [], 'full': False, 'disposed': False, 'version': 10, 'delivered': 1, 'running': False}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': ['a', 'b'], 'next_batch': [], 'full': False, 'version': 11, 'scheduled_after': False, 'stale': True, 'reentrant': False, 'retained': ['a', 'b']}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 10, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 10, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})]}
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:
Repeated invalidation produces duplicate observer field callbacks; the returned lifecycle plan violates the stated transition contract.

Plan a listener invalidation accumulator. Dirty field names form an insertion-ordered set; repeated invalidation keeps first order. Exactly one microtask is requested while dirty and unscheduled. A flush atomically detaches the current fields, so dirt arriving during callbacks becomes a later batch. Full invalidation supersedes field names. Disposed observers drop both batches. 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: fields = list(dict.fromkeys(s['dirty']+([s['incoming']] if s['incoming'] is not None else []))); schedule = bool(s['dirty'] or s['incoming'] is not None or s['full']) and not s['scheduled'] and not s['disposed']; flush_fields = list(dict.fromkeys(s['dirty'])) if s['flush'] and not s['disposed'] and not s['full'] else []; next_batch = list(dict.fromkeys(s['during'])) if s['flush'] and not s['disposed'] else []; full = s['full'] and s['flush'] and not s['disposed']; version = s['version']+int(s['flush'] and bool(s['dirty'] or s['full']) and not s['disposed']); scheduled_after = bool(s['during']) if s['flush'] else s['scheduled']; stale = s['delivered']<s['version']; reentrant = s['flush'] and s['running']; retained = [] if s['disposed'] else list(dict.fromkeys(s['dirty']))

split: open-access


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

N = 1
observations = []
def solve(s):
    return {
        'fields': list(dict.fromkeys(s['dirty']+([s['incoming']] if s['incoming'] is not None else []))),
        'schedule': bool(s['dirty']),
        'flush_fields': list(dict.fromkeys(s['dirty'])) if s['flush'] and not s['disposed'] and not s['full'] else [],
        'next_batch': list(dict.fromkeys(s['during'])) if s['flush'] and not s['disposed'] else [],
        'full': s['full'] and s['flush'] and not s['disposed'],
        'version': s['version']+int(s['flush'] and bool(s['dirty'] or s['full']) and not s['disposed']),
        'scheduled_after': bool(s['during']) if s['flush'] else s['scheduled'],
        'stale': s['delivered']<s['version'],
        'reentrant': s['flush'] and s['running'],
        'retained': [] if s['disposed'] else list(dict.fromkeys(s['dirty'])),
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 2, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': ['a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': ['a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': False, 'during': ['late'], 'full': True, 'disposed': True, 'version': 2, 'delivered': 1, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': False, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': False, 'disposed': False, 'version': 2, 'delivered': 0, 'running': False}, {'fields': ['a', 'b', 'c'], 'schedule': True, 'flush_fields': ['a', 'b'], 'next_batch': ['late'], 'full': False, 'version': 3, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': ['a', 'b']}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': [], 'full': True, 'disposed': True, 'version': 2, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': False, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 2, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 2: [({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'a', 'scheduled': True, 'flush': False, 'during': [], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': ['a', 'b'], 'next_batch': ['late'], 'full': False, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': ['a', 'b']}), ({'dirty': ['c', 'a'], 'incoming': None, 'scheduled': False, 'flush': False, 'during': ['late'], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a'], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': False}, {'fields': ['a', 'c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 3: [({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': []}), ({'dirty': ['a'], 'incoming': 'a', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': ['a']}), ({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a'], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['a', 'c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': ['a']}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': True, 'during': [], 'full': False, 'disposed': False, 'version': 6, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 6, 'scheduled_after': False, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 6, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 6, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 6, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 6, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 4: [({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': False, 'during': ['late'], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': [], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['a', 'b', 'c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': [], 'full': False, 'disposed': True, 'version': 8, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 8, 'scheduled_after': False, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': False, 'version': 8, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 8, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 8, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 8, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 5: [({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 10, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 11, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': False, 'during': [], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': [], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': [], 'full': False, 'disposed': False, 'version': 10, 'delivered': 1, 'running': False}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': ['a', 'b'], 'next_batch': [], 'full': False, 'version': 11, 'scheduled_after': False, 'stale': True, 'reentrant': False, 'retained': ['a', 'b']}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 10, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 10, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})]}
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 {
        'fields': list(dict.fromkeys(s['dirty']+([s['incoming']] if s['incoming'] is not None else []))),
        'schedule': bool(s['dirty'] or s['incoming'] is not None or s['full']) and not s['disposed'],
        'flush_fields': list(dict.fromkeys(s['dirty'])) if s['flush'] and not s['disposed'] and not s['full'] else [],
        'next_batch': list(dict.fromkeys(s['during'])) if s['flush'] and not s['disposed'] else [],
        'full': s['full'] and s['flush'] and not s['disposed'],
        'version': s['version']+int(s['flush'] and bool(s['dirty'] or s['full']) and not s['disposed']),
        'scheduled_after': bool(s['during']) if s['flush'] else s['scheduled'],
        'stale': s['delivered']<s['version'],
        'reentrant': s['flush'] and s['running'],
        'retained': [] if s['disposed'] else list(dict.fromkeys(s['dirty'])),
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 2, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': ['a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': ['a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': False, 'during': ['late'], 'full': True, 'disposed': True, 'version': 2, 'delivered': 1, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': False, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': False, 'disposed': False, 'version': 2, 'delivered': 0, 'running': False}, {'fields': ['a', 'b', 'c'], 'schedule': True, 'flush_fields': ['a', 'b'], 'next_batch': ['late'], 'full': False, 'version': 3, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': ['a', 'b']}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': [], 'full': True, 'disposed': True, 'version': 2, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': False, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 2, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 2, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 2: [({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'a', 'scheduled': True, 'flush': False, 'during': [], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': ['a', 'b'], 'next_batch': ['late'], 'full': False, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': ['a', 'b']}), ({'dirty': ['c', 'a'], 'incoming': None, 'scheduled': False, 'flush': False, 'during': ['late'], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a'], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': False}, {'fields': ['a', 'c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 4, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 4, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 3: [({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': []}), ({'dirty': ['a'], 'incoming': 'a', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': ['a']}), ({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a'], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['a', 'c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': ['a']}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': True, 'during': [], 'full': False, 'disposed': False, 'version': 6, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 6, 'scheduled_after': False, 'stale': True, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 6, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 6, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 6, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 6, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 4: [({'dirty': ['c', 'a'], 'incoming': 'a', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 1, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': False, 'during': ['late'], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': [], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['a', 'b', 'c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': [], 'full': False, 'disposed': True, 'version': 8, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 8, 'scheduled_after': False, 'stale': True, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': True, 'disposed': False, 'version': 8, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 8, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 8, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 8, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})], 5: [({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': False, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': True, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': False, 'version': 10, 'delivered': 0, 'running': False}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': ['late'], 'full': True, 'version': 11, 'scheduled_after': True, 'stale': True, 'reentrant': False, 'retained': ['c', 'a']}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': True, 'disposed': True, 'version': 0, 'delivered': 1, 'running': True}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': False, 'during': [], 'full': False, 'disposed': True, 'version': 0, 'delivered': 0, 'running': False}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': [], 'incoming': 'c', 'scheduled': True, 'flush': False, 'during': ['late'], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': True}, {'fields': ['c'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': True, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['a', 'b', 'a'], 'incoming': None, 'scheduled': True, 'flush': True, 'during': [], 'full': False, 'disposed': False, 'version': 10, 'delivered': 1, 'running': False}, {'fields': ['a', 'b'], 'schedule': False, 'flush_fields': ['a', 'b'], 'next_batch': [], 'full': False, 'version': 11, 'scheduled_after': False, 'stale': True, 'reentrant': False, 'retained': ['a', 'b']}), ({'dirty': [], 'incoming': None, 'scheduled': False, 'flush': False, 'during': [], 'full': False, 'disposed': False, 'version': 0, 'delivered': 0, 'running': False}, {'fields': [], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 0, 'scheduled_after': False, 'stale': False, 'reentrant': False, 'retained': []}), ({'dirty': ['c', 'a'], 'incoming': 'c', 'scheduled': True, 'flush': True, 'during': ['late'], 'full': True, 'disposed': True, 'version': 10, 'delivered': 1, 'running': True}, {'fields': ['c', 'a'], 'schedule': False, 'flush_fields': [], 'next_batch': [], 'full': False, 'version': 10, 'scheduled_after': True, 'stale': True, 'reentrant': True, 'retained': []})]}
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:
Each invalidation creates another microtask while one is scheduled; the returned lifecycle plan violates the stated transition contract.

Plan a listener invalidation accumulator. Dirty field names form an insertion-ordered set; repeated invalidation keeps first order. Exactly one microtask is requested while dirty and unscheduled. A flush atomically detaches the current fields, so dirt arriving during callbacks becomes a later batch. Full invalidation supersedes field names. Disposed observers drop both batches. 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: fields = list(dict.fromkeys(s['dirty']+([s['incoming']] if s['incoming'] is not None else []))); schedule = bool(s['dirty'] or s['incoming'] is not None or s['full']) and not s['scheduled'] and not s['disposed']; flush_fields = list(dict.fromkeys(s['dirty'])) if s['flush'] and not s['disposed'] and not s['full'] else []; next_batch = list(dict.fromkeys(s['during'])) if s['flush'] and not s['disposed'] else []; full = s['full'] and s['flush'] and not s['disposed']; version = s['version']+int(s['flush'] and bool(s['dirty'] or s['full']) and not s['disposed']); scheduled_after = bool(s['during']) if s['flush'] else s['scheduled']; stale = s['delivered']<s['version']; reentrant = s['flush'] and s['running']; retained = [] if s['disposed'] else list(dict.fromkeys(s['dirty']))

split: open-access