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

N = 1
observations = []
def solve(s):
    return {
        'invoke': s['registered'] and (s['alive'] or s['strong']) and not s['finalized'] and s['context_alive'] and s['callback'],
        'pin': s['dispatching'] and (s['alive'] or s['strong']) and not s['finalized'],
        'tombstone': s['tombstone'] or s['finalized'] or (not s['alive'] and not s['strong']),
        'sweep': s['sweep'] and s['tombstone'] and not s['dispatching'],
        'context': not s['context_alive'],
        'pins': 0,
        'retain': s['strong'] and not s['finalized'],
        'resurrect': False,
        'orphan': s['method'] if s['method'] in s['methods'] else None,
        'defer': s['sweep'] and s['tombstone'] and s['dispatching'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 2, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 1, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': True, 'finalized': True, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 2, 'sweep': True, 'callback': True, 'registered': False, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 2, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': False, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 2, 'sweep': False, 'callback': False, 'registered': False, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': False, 'sweep': False, 'context': False, 'pins': 2, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': True, 'registered': True, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': False, 'tombstone': True, 'pins': 2, 'sweep': True, 'callback': False, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': True, 'context': True, 'pins': 2, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 2, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 1, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 2: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 4, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 3, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': True, 'finalized': True, 'strong': False, 'context_alive': True, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': False, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': False, 'strong': True, 'context_alive': True, 'dispatching': False, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': False, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': True, 'context': False, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 4, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 3, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 3: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 6, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 5, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': True}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 6, 'sweep': True, 'callback': False, 'registered': False, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': False, 'sweep': False, 'context': False, 'pins': 6, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': False, 'tombstone': True, 'pins': 0, 'sweep': False, 'callback': False, 'registered': True, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 6, 'sweep': False, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 5, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': True, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': False, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 6, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 5, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 4: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 8, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 7, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': True, 'finalized': True, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': True, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': True, 'strong': False, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 8, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 7, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 5: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 10, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 9, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': False, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': True, 'registered': False, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': False, 'finalized': False, 'strong': True, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': True, 'pin': False, 'tombstone': False, 'sweep': False, 'context': False, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': True, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 10, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 9, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': True, 'registered': False, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': False, 'sweep': False, 'context': True, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 10, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 9, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': 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 {
        'invoke': s['registered'] and (s['alive'] or s['strong']) and not s['finalized'] and s['context_alive'] and s['callback'],
        'pin': s['dispatching'] and (s['alive'] or s['strong']) and not s['finalized'],
        'tombstone': s['tombstone'] or s['finalized'] or (not s['alive'] and not s['strong']),
        'sweep': s['sweep'] and s['tombstone'] and not s['dispatching'],
        'context': not s['context_alive'],
        'pins': s['pins']-int(s['dispatching']),
        'retain': s['strong'] and not s['finalized'],
        'resurrect': False,
        'orphan': s['method'] if s['method'] in s['methods'] else None,
        'defer': s['sweep'] and s['tombstone'] and s['dispatching'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 2, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 1, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': True, 'finalized': True, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 2, 'sweep': True, 'callback': True, 'registered': False, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 2, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': False, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 2, 'sweep': False, 'callback': False, 'registered': False, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': False, 'sweep': False, 'context': False, 'pins': 2, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': True, 'registered': True, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': False, 'tombstone': True, 'pins': 2, 'sweep': True, 'callback': False, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': True, 'context': True, 'pins': 2, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 2, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 1, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 2: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 4, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 3, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': True, 'finalized': True, 'strong': False, 'context_alive': True, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': False, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': False, 'strong': True, 'context_alive': True, 'dispatching': False, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': False, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': True, 'context': False, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 4, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 3, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 3: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 6, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 5, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': True}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 6, 'sweep': True, 'callback': False, 'registered': False, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': False, 'sweep': False, 'context': False, 'pins': 6, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': False, 'tombstone': True, 'pins': 0, 'sweep': False, 'callback': False, 'registered': True, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 6, 'sweep': False, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 5, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': True, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': False, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 6, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 5, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 4: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 8, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 7, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': True, 'finalized': True, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': True, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': True, 'strong': False, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 8, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 7, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 5: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 10, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 9, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': False, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': True, 'registered': False, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': False, 'finalized': False, 'strong': True, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': True, 'pin': False, 'tombstone': False, 'sweep': False, 'context': False, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': True, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 10, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 9, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': True, 'registered': False, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': False, 'sweep': False, 'context': True, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 10, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 9, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': 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:
Callback exit drops every outstanding weak-target pin; the returned lifecycle plan violates the stated transition contract.

Resolve a weakly owned observer target at dispatch time. A dead or finalized target is skipped, its registration becomes a tombstone, and a live target is pinned only for the callback. Sweep only tombstones outside dispatch. A strong-owner override prevents collection but does not revive a finalized target. Dead callback contexts are also excluded. A weak method binding resolves its exact method name or becomes absent; a different extant fallback method is never invoked. 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: invoke = s['registered'] and (s['alive'] or s['strong']) and not s['finalized'] and s['context_alive'] and s['callback']; pin = s['dispatching'] and (s['alive'] or s['strong']) and not s['finalized']; tombstone = s['tombstone'] or s['finalized'] or (not s['alive'] and not s['strong']); sweep = s['sweep'] and s['tombstone'] and not s['dispatching']; context = not s['context_alive']; pins = max(0,s['pins']-int(s['dispatching'])); retain = s['strong'] and not s['finalized']; resurrect = False; orphan = s['method'] if s['method'] in s['methods'] else None; defer = s['sweep'] and s['tombstone'] and s['dispatching']

split: open-access


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

N = 1
observations = []
def solve(s):
    return {
        'invoke': s['registered'] and (s['alive'] or s['strong']) and not s['finalized'] and s['context_alive'] and s['callback'],
        'pin': s['dispatching'] and (s['alive'] or s['strong']) and not s['finalized'],
        'tombstone': s['tombstone'] or s['finalized'] or (not s['alive'] and not s['strong']),
        'sweep': s['sweep'] and s['tombstone'] and not s['dispatching'],
        'context': not s['context_alive'],
        'pins': max(0,s['pins']-int(s['dispatching'])),
        'retain': s['registered'],
        'resurrect': False,
        'orphan': s['method'] if s['method'] in s['methods'] else None,
        'defer': s['sweep'] and s['tombstone'] and s['dispatching'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 2, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 1, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': True, 'finalized': True, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 2, 'sweep': True, 'callback': True, 'registered': False, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 2, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': False, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 2, 'sweep': False, 'callback': False, 'registered': False, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': False, 'sweep': False, 'context': False, 'pins': 2, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': True, 'registered': True, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': False, 'tombstone': True, 'pins': 2, 'sweep': True, 'callback': False, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': True, 'context': True, 'pins': 2, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 2, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 1, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 2: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 4, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 3, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': True, 'finalized': True, 'strong': False, 'context_alive': True, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': False, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': False, 'strong': True, 'context_alive': True, 'dispatching': False, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': False, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': True, 'context': False, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 4, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 3, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 3: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 6, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 5, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': True}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 6, 'sweep': True, 'callback': False, 'registered': False, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': False, 'sweep': False, 'context': False, 'pins': 6, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': False, 'tombstone': True, 'pins': 0, 'sweep': False, 'callback': False, 'registered': True, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 6, 'sweep': False, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 5, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': True, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': False, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 6, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 5, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 4: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 8, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 7, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': True, 'finalized': True, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': True, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': True, 'strong': False, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 8, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 7, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 5: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 10, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 9, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': False, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': True, 'registered': False, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': False, 'finalized': False, 'strong': True, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': True, 'pin': False, 'tombstone': False, 'sweep': False, 'context': False, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': True, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 10, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 9, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': True, 'registered': False, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': False, 'sweep': False, 'context': True, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 10, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 9, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': 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 {
        'invoke': s['registered'] and (s['alive'] or s['strong']) and not s['finalized'] and s['context_alive'] and s['callback'],
        'pin': s['dispatching'] and (s['alive'] or s['strong']) and not s['finalized'],
        'tombstone': s['tombstone'] or s['finalized'] or (not s['alive'] and not s['strong']),
        'sweep': s['sweep'] and s['tombstone'] and not s['dispatching'],
        'context': not s['context_alive'],
        'pins': max(0,s['pins']-int(s['dispatching'])),
        'retain': s['strong'],
        'resurrect': False,
        'orphan': s['method'] if s['method'] in s['methods'] else None,
        'defer': s['sweep'] and s['tombstone'] and s['dispatching'],
    }
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 2, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 1, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': True, 'finalized': True, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 2, 'sweep': True, 'callback': True, 'registered': False, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 2, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': False, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 2, 'sweep': False, 'callback': False, 'registered': False, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': False, 'sweep': False, 'context': False, 'pins': 2, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': True, 'registered': True, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': False, 'tombstone': True, 'pins': 2, 'sweep': True, 'callback': False, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': True, 'context': True, 'pins': 2, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 2, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 1, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 2: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 4, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 3, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': True, 'finalized': True, 'strong': False, 'context_alive': True, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': False, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': False, 'strong': True, 'context_alive': True, 'dispatching': False, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': False, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': True, 'context': False, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 4, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 3, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 3: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 6, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 5, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': True}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 6, 'sweep': True, 'callback': False, 'registered': False, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': False, 'sweep': False, 'context': False, 'pins': 6, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': False, 'tombstone': True, 'pins': 0, 'sweep': False, 'callback': False, 'registered': True, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 6, 'sweep': False, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 5, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': True, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': False, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 6, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 5, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 4: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': True, 'pins': 8, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 7, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': True, 'finalized': True, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': True, 'strong': False, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': 'on_data', 'defer': False}), ({'alive': False, 'finalized': True, 'strong': False, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 8, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 7, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True})], 5: [({'alive': True, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 10, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 9, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': False, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 0, 'sweep': True, 'callback': True, 'registered': False, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': True}), ({'alive': False, 'finalized': False, 'strong': True, 'context_alive': True, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': True, 'pin': False, 'tombstone': False, 'sweep': False, 'context': False, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': True, 'callback': False, 'registered': True, 'method': 'missing', 'methods': ['on_data'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': True, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 10, 'sweep': True, 'callback': True, 'registered': True, 'method': 'on_data', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 9, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': False, 'strong': True, 'context_alive': False, 'dispatching': True, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': True, 'registered': False, 'method': 'missing', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': True, 'tombstone': False, 'sweep': False, 'context': True, 'pins': 0, 'retain': True, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': False, 'finalized': False, 'strong': False, 'context_alive': False, 'dispatching': False, 'tombstone': False, 'pins': 0, 'sweep': False, 'callback': False, 'registered': False, 'method': 'on_data', 'methods': [], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': True, 'pins': 0, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': False}), ({'alive': True, 'finalized': True, 'strong': True, 'context_alive': True, 'dispatching': True, 'tombstone': True, 'pins': 10, 'sweep': True, 'callback': True, 'registered': True, 'method': 'missing', 'methods': ['fallback'], 'fallback': 'fallback'}, {'invoke': False, 'pin': False, 'tombstone': True, 'sweep': False, 'context': False, 'pins': 9, 'retain': False, 'resurrect': False, 'orphan': None, 'defer': 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:
A weak registration itself retains the observer target; the returned lifecycle plan violates the stated transition contract.

Resolve a weakly owned observer target at dispatch time. A dead or finalized target is skipped, its registration becomes a tombstone, and a live target is pinned only for the callback. Sweep only tombstones outside dispatch. A strong-owner override prevents collection but does not revive a finalized target. Dead callback contexts are also excluded. A weak method binding resolves its exact method name or becomes absent; a different extant fallback method is never invoked. 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: invoke = s['registered'] and (s['alive'] or s['strong']) and not s['finalized'] and s['context_alive'] and s['callback']; pin = s['dispatching'] and (s['alive'] or s['strong']) and not s['finalized']; tombstone = s['tombstone'] or s['finalized'] or (not s['alive'] and not s['strong']); sweep = s['sweep'] and s['tombstone'] and not s['dispatching']; context = not s['context_alive']; pins = max(0,s['pins']-int(s['dispatching'])); retain = s['strong'] and not s['finalized']; resurrect = False; orphan = s['method'] if s['method'] in s['methods'] else None; defer = s['sweep'] and s['tombstone'] and s['dispatching']

split: open-access