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

N = 1
observations = []
def solve(operation, s):
    visible, online, interval, due, now, in_flight, queued, policy = s
    if operation == 'foreground-tick-admission':
        return online and now>=due
    if operation == 'resume-catchup-coalescing':
        return int(queued>0)
    if operation == 'next-tick-from-now':
        return now+interval
    if operation == 'remaining-delay-clamp':
        return max(0,due-now)
    if operation == 'offline-poll-reason':
        return 'offline' if not online else ('hidden' if not visible and policy!='background' else None)
    if operation == 'inflight-reconnect-dedup':
        return online and not in_flight and queued>0
    if operation == 'hidden-backlog-cap':
        return min(queued,1) if not visible else queued
    if operation == 'background-policy-override':
        return visible or policy=='background'
    if operation == 'timer-install-when-online':
        return interval if online and (visible or policy=='background') else None
    if operation == 'poll-transition-state':
        return 'running' if in_flight else ('waiting' if online and (visible or policy=='background') else 'paused')
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('foreground-tick-admission scenario 1', solve('foreground-tick-admission', (True,True,N+2,5,5,False,3,'foreground')), True)
check('foreground-tick-admission scenario 2', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'foreground')), False)
check('foreground-tick-admission scenario 3', solve('foreground-tick-admission', (True,False,3,5,9,False,1,'foreground')), False)
check('foreground-tick-admission scenario 4', solve('foreground-tick-admission', (True,True,3,5,9,True,0,'foreground')), False)
check('foreground-tick-admission scenario 5', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'background')), True)
check('foreground-tick-admission scenario 6', solve('foreground-tick-admission', (True,True,3,12,9,False,0,'foreground')), False)
check('resume-catchup-coalescing scenario 1', solve('resume-catchup-coalescing', (True,True,N+2,5,5,False,3,'foreground')), 1)
check('resume-catchup-coalescing scenario 2', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'foreground')), 1)
check('resume-catchup-coalescing scenario 3', solve('resume-catchup-coalescing', (True,False,3,5,9,False,1,'foreground')), 1)
check('resume-catchup-coalescing scenario 4', solve('resume-catchup-coalescing', (True,True,3,5,9,True,0,'foreground')), 0)
check('resume-catchup-coalescing scenario 5', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'background')), 1)
check('resume-catchup-coalescing scenario 6', solve('resume-catchup-coalescing', (True,True,3,12,9,False,0,'foreground')), 0)
check('next-tick-from-now scenario 1', solve('next-tick-from-now', (True,True,N+2,5,5,False,3,'foreground')), N+7)
check('next-tick-from-now scenario 2', solve('next-tick-from-now', (False,True,3,5,9,False,2,'foreground')), 12)
check('next-tick-from-now scenario 3', solve('next-tick-from-now', (True,False,3,5,9,False,1,'foreground')), 12)
check('next-tick-from-now scenario 4', solve('next-tick-from-now', (True,True,3,5,9,True,0,'foreground')), 12)
check('next-tick-from-now scenario 5', solve('next-tick-from-now', (False,True,3,5,9,False,2,'background')), 12)
check('next-tick-from-now scenario 6', solve('next-tick-from-now', (True,True,3,12,9,False,0,'foreground')), 12)
check('remaining-delay-clamp scenario 1', solve('remaining-delay-clamp', (True,True,N+2,5,5,False,3,'foreground')), 0)
check('remaining-delay-clamp scenario 2', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'foreground')), 0)
check('remaining-delay-clamp scenario 3', solve('remaining-delay-clamp', (True,False,3,5,9,False,1,'foreground')), 0)
check('remaining-delay-clamp scenario 4', solve('remaining-delay-clamp', (True,True,3,5,9,True,0,'foreground')), 0)
check('remaining-delay-clamp scenario 5', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'background')), 0)
check('remaining-delay-clamp scenario 6', solve('remaining-delay-clamp', (True,True,3,12,9,False,0,'foreground')), 3)
check('offline-poll-reason scenario 1', solve('offline-poll-reason', (True,True,N+2,5,5,False,3,'foreground')), None)
check('offline-poll-reason scenario 2', solve('offline-poll-reason', (False,True,3,5,9,False,2,'foreground')), 'hidden')
check('offline-poll-reason scenario 3', solve('offline-poll-reason', (True,False,3,5,9,False,1,'foreground')), 'offline')
check('offline-poll-reason scenario 4', solve('offline-poll-reason', (True,True,3,5,9,True,0,'foreground')), None)
check('offline-poll-reason scenario 5', solve('offline-poll-reason', (False,True,3,5,9,False,2,'background')), None)
check('offline-poll-reason scenario 6', solve('offline-poll-reason', (True,True,3,12,9,False,0,'foreground')), None)
check('inflight-reconnect-dedup scenario 1', solve('inflight-reconnect-dedup', (True,True,N+2,5,5,False,3,'foreground')), True)
check('inflight-reconnect-dedup scenario 2', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'foreground')), True)
check('inflight-reconnect-dedup scenario 3', solve('inflight-reconnect-dedup', (True,False,3,5,9,False,1,'foreground')), False)
check('inflight-reconnect-dedup scenario 4', solve('inflight-reconnect-dedup', (True,True,3,5,9,True,0,'foreground')), False)
check('inflight-reconnect-dedup scenario 5', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'background')), True)
check('inflight-reconnect-dedup scenario 6', solve('inflight-reconnect-dedup', (True,True,3,12,9,False,0,'foreground')), False)
check('hidden-backlog-cap scenario 1', solve('hidden-backlog-cap', (True,True,N+2,5,5,False,3,'foreground')), 3)
check('hidden-backlog-cap scenario 2', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'foreground')), 1)
check('hidden-backlog-cap scenario 3', solve('hidden-backlog-cap', (True,False,3,5,9,False,1,'foreground')), 1)
check('hidden-backlog-cap scenario 4', solve('hidden-backlog-cap', (True,True,3,5,9,True,0,'foreground')), 0)
check('hidden-backlog-cap scenario 5', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'background')), 1)
check('hidden-backlog-cap scenario 6', solve('hidden-backlog-cap', (True,True,3,12,9,False,0,'foreground')), 0)
check('background-policy-override scenario 1', solve('background-policy-override', (True,True,N+2,5,5,False,3,'foreground')), True)
check('background-policy-override scenario 2', solve('background-policy-override', (False,True,3,5,9,False,2,'foreground')), False)
check('background-policy-override scenario 3', solve('background-policy-override', (True,False,3,5,9,False,1,'foreground')), True)
check('background-policy-override scenario 4', solve('background-policy-override', (True,True,3,5,9,True,0,'foreground')), True)
check('background-policy-override scenario 5', solve('background-policy-override', (False,True,3,5,9,False,2,'background')), True)
check('background-policy-override scenario 6', solve('background-policy-override', (True,True,3,12,9,False,0,'foreground')), True)
check('timer-install-when-online scenario 1', solve('timer-install-when-online', (True,True,N+2,5,5,False,3,'foreground')), N+2)
check('timer-install-when-online scenario 2', solve('timer-install-when-online', (False,True,3,5,9,False,2,'foreground')), None)
check('timer-install-when-online scenario 3', solve('timer-install-when-online', (True,False,3,5,9,False,1,'foreground')), None)
check('timer-install-when-online scenario 4', solve('timer-install-when-online', (True,True,3,5,9,True,0,'foreground')), 3)
check('timer-install-when-online scenario 5', solve('timer-install-when-online', (False,True,3,5,9,False,2,'background')), 3)
check('timer-install-when-online scenario 6', solve('timer-install-when-online', (True,True,3,12,9,False,0,'foreground')), 3)
check('poll-transition-state scenario 1', solve('poll-transition-state', (True,True,N+2,5,5,False,3,'foreground')), 'waiting')
check('poll-transition-state scenario 2', solve('poll-transition-state', (False,True,3,5,9,False,2,'foreground')), 'paused')
check('poll-transition-state scenario 3', solve('poll-transition-state', (True,False,3,5,9,False,1,'foreground')), 'paused')
check('poll-transition-state scenario 4', solve('poll-transition-state', (True,True,3,5,9,True,0,'foreground')), 'running')
check('poll-transition-state scenario 5', solve('poll-transition-state', (False,True,3,5,9,False,2,'background')), 'waiting')
check('poll-transition-state scenario 6', solve('poll-transition-state', (True,True,3,12,9,False,0,'foreground')), 'waiting')
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(operation, s):
    visible, online, interval, due, now, in_flight, queued, policy = s
    if operation == 'foreground-tick-admission':
        return visible and online and not in_flight and now>=due
    if operation == 'resume-catchup-coalescing':
        return int(queued>0)
    if operation == 'next-tick-from-now':
        return now+interval
    if operation == 'remaining-delay-clamp':
        return max(0,due-now)
    if operation == 'offline-poll-reason':
        return 'offline' if not online else ('hidden' if not visible and policy!='background' else None)
    if operation == 'inflight-reconnect-dedup':
        return online and not in_flight and queued>0
    if operation == 'hidden-backlog-cap':
        return min(queued,1) if not visible else queued
    if operation == 'background-policy-override':
        return visible or policy=='background'
    if operation == 'timer-install-when-online':
        return interval if online and (visible or policy=='background') else None
    if operation == 'poll-transition-state':
        return 'running' if in_flight else ('waiting' if online and (visible or policy=='background') else 'paused')
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('foreground-tick-admission scenario 1', solve('foreground-tick-admission', (True,True,N+2,5,5,False,3,'foreground')), True)
check('foreground-tick-admission scenario 2', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'foreground')), False)
check('foreground-tick-admission scenario 3', solve('foreground-tick-admission', (True,False,3,5,9,False,1,'foreground')), False)
check('foreground-tick-admission scenario 4', solve('foreground-tick-admission', (True,True,3,5,9,True,0,'foreground')), False)
check('foreground-tick-admission scenario 5', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'background')), True)
check('foreground-tick-admission scenario 6', solve('foreground-tick-admission', (True,True,3,12,9,False,0,'foreground')), False)
check('resume-catchup-coalescing scenario 1', solve('resume-catchup-coalescing', (True,True,N+2,5,5,False,3,'foreground')), 1)
check('resume-catchup-coalescing scenario 2', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'foreground')), 1)
check('resume-catchup-coalescing scenario 3', solve('resume-catchup-coalescing', (True,False,3,5,9,False,1,'foreground')), 1)
check('resume-catchup-coalescing scenario 4', solve('resume-catchup-coalescing', (True,True,3,5,9,True,0,'foreground')), 0)
check('resume-catchup-coalescing scenario 5', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'background')), 1)
check('resume-catchup-coalescing scenario 6', solve('resume-catchup-coalescing', (True,True,3,12,9,False,0,'foreground')), 0)
check('next-tick-from-now scenario 1', solve('next-tick-from-now', (True,True,N+2,5,5,False,3,'foreground')), N+7)
check('next-tick-from-now scenario 2', solve('next-tick-from-now', (False,True,3,5,9,False,2,'foreground')), 12)
check('next-tick-from-now scenario 3', solve('next-tick-from-now', (True,False,3,5,9,False,1,'foreground')), 12)
check('next-tick-from-now scenario 4', solve('next-tick-from-now', (True,True,3,5,9,True,0,'foreground')), 12)
check('next-tick-from-now scenario 5', solve('next-tick-from-now', (False,True,3,5,9,False,2,'background')), 12)
check('next-tick-from-now scenario 6', solve('next-tick-from-now', (True,True,3,12,9,False,0,'foreground')), 12)
check('remaining-delay-clamp scenario 1', solve('remaining-delay-clamp', (True,True,N+2,5,5,False,3,'foreground')), 0)
check('remaining-delay-clamp scenario 2', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'foreground')), 0)
check('remaining-delay-clamp scenario 3', solve('remaining-delay-clamp', (True,False,3,5,9,False,1,'foreground')), 0)
check('remaining-delay-clamp scenario 4', solve('remaining-delay-clamp', (True,True,3,5,9,True,0,'foreground')), 0)
check('remaining-delay-clamp scenario 5', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'background')), 0)
check('remaining-delay-clamp scenario 6', solve('remaining-delay-clamp', (True,True,3,12,9,False,0,'foreground')), 3)
check('offline-poll-reason scenario 1', solve('offline-poll-reason', (True,True,N+2,5,5,False,3,'foreground')), None)
check('offline-poll-reason scenario 2', solve('offline-poll-reason', (False,True,3,5,9,False,2,'foreground')), 'hidden')
check('offline-poll-reason scenario 3', solve('offline-poll-reason', (True,False,3,5,9,False,1,'foreground')), 'offline')
check('offline-poll-reason scenario 4', solve('offline-poll-reason', (True,True,3,5,9,True,0,'foreground')), None)
check('offline-poll-reason scenario 5', solve('offline-poll-reason', (False,True,3,5,9,False,2,'background')), None)
check('offline-poll-reason scenario 6', solve('offline-poll-reason', (True,True,3,12,9,False,0,'foreground')), None)
check('inflight-reconnect-dedup scenario 1', solve('inflight-reconnect-dedup', (True,True,N+2,5,5,False,3,'foreground')), True)
check('inflight-reconnect-dedup scenario 2', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'foreground')), True)
check('inflight-reconnect-dedup scenario 3', solve('inflight-reconnect-dedup', (True,False,3,5,9,False,1,'foreground')), False)
check('inflight-reconnect-dedup scenario 4', solve('inflight-reconnect-dedup', (True,True,3,5,9,True,0,'foreground')), False)
check('inflight-reconnect-dedup scenario 5', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'background')), True)
check('inflight-reconnect-dedup scenario 6', solve('inflight-reconnect-dedup', (True,True,3,12,9,False,0,'foreground')), False)
check('hidden-backlog-cap scenario 1', solve('hidden-backlog-cap', (True,True,N+2,5,5,False,3,'foreground')), 3)
check('hidden-backlog-cap scenario 2', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'foreground')), 1)
check('hidden-backlog-cap scenario 3', solve('hidden-backlog-cap', (True,False,3,5,9,False,1,'foreground')), 1)
check('hidden-backlog-cap scenario 4', solve('hidden-backlog-cap', (True,True,3,5,9,True,0,'foreground')), 0)
check('hidden-backlog-cap scenario 5', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'background')), 1)
check('hidden-backlog-cap scenario 6', solve('hidden-backlog-cap', (True,True,3,12,9,False,0,'foreground')), 0)
check('background-policy-override scenario 1', solve('background-policy-override', (True,True,N+2,5,5,False,3,'foreground')), True)
check('background-policy-override scenario 2', solve('background-policy-override', (False,True,3,5,9,False,2,'foreground')), False)
check('background-policy-override scenario 3', solve('background-policy-override', (True,False,3,5,9,False,1,'foreground')), True)
check('background-policy-override scenario 4', solve('background-policy-override', (True,True,3,5,9,True,0,'foreground')), True)
check('background-policy-override scenario 5', solve('background-policy-override', (False,True,3,5,9,False,2,'background')), True)
check('background-policy-override scenario 6', solve('background-policy-override', (True,True,3,12,9,False,0,'foreground')), True)
check('timer-install-when-online scenario 1', solve('timer-install-when-online', (True,True,N+2,5,5,False,3,'foreground')), N+2)
check('timer-install-when-online scenario 2', solve('timer-install-when-online', (False,True,3,5,9,False,2,'foreground')), None)
check('timer-install-when-online scenario 3', solve('timer-install-when-online', (True,False,3,5,9,False,1,'foreground')), None)
check('timer-install-when-online scenario 4', solve('timer-install-when-online', (True,True,3,5,9,True,0,'foreground')), 3)
check('timer-install-when-online scenario 5', solve('timer-install-when-online', (False,True,3,5,9,False,2,'background')), 3)
check('timer-install-when-online scenario 6', solve('timer-install-when-online', (True,True,3,12,9,False,0,'foreground')), 3)
check('poll-transition-state scenario 1', solve('poll-transition-state', (True,True,N+2,5,5,False,3,'foreground')), 'waiting')
check('poll-transition-state scenario 2', solve('poll-transition-state', (False,True,3,5,9,False,2,'foreground')), 'paused')
check('poll-transition-state scenario 3', solve('poll-transition-state', (True,False,3,5,9,False,1,'foreground')), 'paused')
check('poll-transition-state scenario 4', solve('poll-transition-state', (True,True,3,5,9,True,0,'foreground')), 'running')
check('poll-transition-state scenario 5', solve('poll-transition-state', (False,True,3,5,9,False,2,'background')), 'waiting')
check('poll-transition-state scenario 6', solve('poll-transition-state', (True,True,3,12,9,False,0,'foreground')), 'waiting')
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:
Foreground tick admission.

Only one poll may be in flight. Foreground polling pauses offline or hidden; a background policy permits hidden work. Missed ticks coalesce into one catch-up request and scheduling restarts relative to the current clock. Operation foreground-tick-admission has the six explicit input/output oracles below.

split: open-access


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

N = 1
observations = []
def solve(operation, s):
    visible, online, interval, due, now, in_flight, queued, policy = s
    if operation == 'foreground-tick-admission':
        return online and (visible or policy=='background') and not in_flight and now>=due
    if operation == 'resume-catchup-coalescing':
        return queued
    if operation == 'next-tick-from-now':
        return now+interval
    if operation == 'remaining-delay-clamp':
        return max(0,due-now)
    if operation == 'offline-poll-reason':
        return 'offline' if not online else ('hidden' if not visible and policy!='background' else None)
    if operation == 'inflight-reconnect-dedup':
        return online and not in_flight and queued>0
    if operation == 'hidden-backlog-cap':
        return min(queued,1) if not visible else queued
    if operation == 'background-policy-override':
        return visible or policy=='background'
    if operation == 'timer-install-when-online':
        return interval if online and (visible or policy=='background') else None
    if operation == 'poll-transition-state':
        return 'running' if in_flight else ('waiting' if online and (visible or policy=='background') else 'paused')
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('foreground-tick-admission scenario 1', solve('foreground-tick-admission', (True,True,N+2,5,5,False,3,'foreground')), True)
check('foreground-tick-admission scenario 2', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'foreground')), False)
check('foreground-tick-admission scenario 3', solve('foreground-tick-admission', (True,False,3,5,9,False,1,'foreground')), False)
check('foreground-tick-admission scenario 4', solve('foreground-tick-admission', (True,True,3,5,9,True,0,'foreground')), False)
check('foreground-tick-admission scenario 5', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'background')), True)
check('foreground-tick-admission scenario 6', solve('foreground-tick-admission', (True,True,3,12,9,False,0,'foreground')), False)
check('resume-catchup-coalescing scenario 1', solve('resume-catchup-coalescing', (True,True,N+2,5,5,False,3,'foreground')), 1)
check('resume-catchup-coalescing scenario 2', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'foreground')), 1)
check('resume-catchup-coalescing scenario 3', solve('resume-catchup-coalescing', (True,False,3,5,9,False,1,'foreground')), 1)
check('resume-catchup-coalescing scenario 4', solve('resume-catchup-coalescing', (True,True,3,5,9,True,0,'foreground')), 0)
check('resume-catchup-coalescing scenario 5', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'background')), 1)
check('resume-catchup-coalescing scenario 6', solve('resume-catchup-coalescing', (True,True,3,12,9,False,0,'foreground')), 0)
check('next-tick-from-now scenario 1', solve('next-tick-from-now', (True,True,N+2,5,5,False,3,'foreground')), N+7)
check('next-tick-from-now scenario 2', solve('next-tick-from-now', (False,True,3,5,9,False,2,'foreground')), 12)
check('next-tick-from-now scenario 3', solve('next-tick-from-now', (True,False,3,5,9,False,1,'foreground')), 12)
check('next-tick-from-now scenario 4', solve('next-tick-from-now', (True,True,3,5,9,True,0,'foreground')), 12)
check('next-tick-from-now scenario 5', solve('next-tick-from-now', (False,True,3,5,9,False,2,'background')), 12)
check('next-tick-from-now scenario 6', solve('next-tick-from-now', (True,True,3,12,9,False,0,'foreground')), 12)
check('remaining-delay-clamp scenario 1', solve('remaining-delay-clamp', (True,True,N+2,5,5,False,3,'foreground')), 0)
check('remaining-delay-clamp scenario 2', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'foreground')), 0)
check('remaining-delay-clamp scenario 3', solve('remaining-delay-clamp', (True,False,3,5,9,False,1,'foreground')), 0)
check('remaining-delay-clamp scenario 4', solve('remaining-delay-clamp', (True,True,3,5,9,True,0,'foreground')), 0)
check('remaining-delay-clamp scenario 5', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'background')), 0)
check('remaining-delay-clamp scenario 6', solve('remaining-delay-clamp', (True,True,3,12,9,False,0,'foreground')), 3)
check('offline-poll-reason scenario 1', solve('offline-poll-reason', (True,True,N+2,5,5,False,3,'foreground')), None)
check('offline-poll-reason scenario 2', solve('offline-poll-reason', (False,True,3,5,9,False,2,'foreground')), 'hidden')
check('offline-poll-reason scenario 3', solve('offline-poll-reason', (True,False,3,5,9,False,1,'foreground')), 'offline')
check('offline-poll-reason scenario 4', solve('offline-poll-reason', (True,True,3,5,9,True,0,'foreground')), None)
check('offline-poll-reason scenario 5', solve('offline-poll-reason', (False,True,3,5,9,False,2,'background')), None)
check('offline-poll-reason scenario 6', solve('offline-poll-reason', (True,True,3,12,9,False,0,'foreground')), None)
check('inflight-reconnect-dedup scenario 1', solve('inflight-reconnect-dedup', (True,True,N+2,5,5,False,3,'foreground')), True)
check('inflight-reconnect-dedup scenario 2', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'foreground')), True)
check('inflight-reconnect-dedup scenario 3', solve('inflight-reconnect-dedup', (True,False,3,5,9,False,1,'foreground')), False)
check('inflight-reconnect-dedup scenario 4', solve('inflight-reconnect-dedup', (True,True,3,5,9,True,0,'foreground')), False)
check('inflight-reconnect-dedup scenario 5', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'background')), True)
check('inflight-reconnect-dedup scenario 6', solve('inflight-reconnect-dedup', (True,True,3,12,9,False,0,'foreground')), False)
check('hidden-backlog-cap scenario 1', solve('hidden-backlog-cap', (True,True,N+2,5,5,False,3,'foreground')), 3)
check('hidden-backlog-cap scenario 2', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'foreground')), 1)
check('hidden-backlog-cap scenario 3', solve('hidden-backlog-cap', (True,False,3,5,9,False,1,'foreground')), 1)
check('hidden-backlog-cap scenario 4', solve('hidden-backlog-cap', (True,True,3,5,9,True,0,'foreground')), 0)
check('hidden-backlog-cap scenario 5', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'background')), 1)
check('hidden-backlog-cap scenario 6', solve('hidden-backlog-cap', (True,True,3,12,9,False,0,'foreground')), 0)
check('background-policy-override scenario 1', solve('background-policy-override', (True,True,N+2,5,5,False,3,'foreground')), True)
check('background-policy-override scenario 2', solve('background-policy-override', (False,True,3,5,9,False,2,'foreground')), False)
check('background-policy-override scenario 3', solve('background-policy-override', (True,False,3,5,9,False,1,'foreground')), True)
check('background-policy-override scenario 4', solve('background-policy-override', (True,True,3,5,9,True,0,'foreground')), True)
check('background-policy-override scenario 5', solve('background-policy-override', (False,True,3,5,9,False,2,'background')), True)
check('background-policy-override scenario 6', solve('background-policy-override', (True,True,3,12,9,False,0,'foreground')), True)
check('timer-install-when-online scenario 1', solve('timer-install-when-online', (True,True,N+2,5,5,False,3,'foreground')), N+2)
check('timer-install-when-online scenario 2', solve('timer-install-when-online', (False,True,3,5,9,False,2,'foreground')), None)
check('timer-install-when-online scenario 3', solve('timer-install-when-online', (True,False,3,5,9,False,1,'foreground')), None)
check('timer-install-when-online scenario 4', solve('timer-install-when-online', (True,True,3,5,9,True,0,'foreground')), 3)
check('timer-install-when-online scenario 5', solve('timer-install-when-online', (False,True,3,5,9,False,2,'background')), 3)
check('timer-install-when-online scenario 6', solve('timer-install-when-online', (True,True,3,12,9,False,0,'foreground')), 3)
check('poll-transition-state scenario 1', solve('poll-transition-state', (True,True,N+2,5,5,False,3,'foreground')), 'waiting')
check('poll-transition-state scenario 2', solve('poll-transition-state', (False,True,3,5,9,False,2,'foreground')), 'paused')
check('poll-transition-state scenario 3', solve('poll-transition-state', (True,False,3,5,9,False,1,'foreground')), 'paused')
check('poll-transition-state scenario 4', solve('poll-transition-state', (True,True,3,5,9,True,0,'foreground')), 'running')
check('poll-transition-state scenario 5', solve('poll-transition-state', (False,True,3,5,9,False,2,'background')), 'waiting')
check('poll-transition-state scenario 6', solve('poll-transition-state', (True,True,3,12,9,False,0,'foreground')), 'waiting')
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(operation, s):
    visible, online, interval, due, now, in_flight, queued, policy = s
    if operation == 'foreground-tick-admission':
        return online and (visible or policy=='background') and not in_flight and now>=due
    if operation == 'resume-catchup-coalescing':
        return 0
    if operation == 'next-tick-from-now':
        return now+interval
    if operation == 'remaining-delay-clamp':
        return max(0,due-now)
    if operation == 'offline-poll-reason':
        return 'offline' if not online else ('hidden' if not visible and policy!='background' else None)
    if operation == 'inflight-reconnect-dedup':
        return online and not in_flight and queued>0
    if operation == 'hidden-backlog-cap':
        return min(queued,1) if not visible else queued
    if operation == 'background-policy-override':
        return visible or policy=='background'
    if operation == 'timer-install-when-online':
        return interval if online and (visible or policy=='background') else None
    if operation == 'poll-transition-state':
        return 'running' if in_flight else ('waiting' if online and (visible or policy=='background') else 'paused')
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('foreground-tick-admission scenario 1', solve('foreground-tick-admission', (True,True,N+2,5,5,False,3,'foreground')), True)
check('foreground-tick-admission scenario 2', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'foreground')), False)
check('foreground-tick-admission scenario 3', solve('foreground-tick-admission', (True,False,3,5,9,False,1,'foreground')), False)
check('foreground-tick-admission scenario 4', solve('foreground-tick-admission', (True,True,3,5,9,True,0,'foreground')), False)
check('foreground-tick-admission scenario 5', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'background')), True)
check('foreground-tick-admission scenario 6', solve('foreground-tick-admission', (True,True,3,12,9,False,0,'foreground')), False)
check('resume-catchup-coalescing scenario 1', solve('resume-catchup-coalescing', (True,True,N+2,5,5,False,3,'foreground')), 1)
check('resume-catchup-coalescing scenario 2', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'foreground')), 1)
check('resume-catchup-coalescing scenario 3', solve('resume-catchup-coalescing', (True,False,3,5,9,False,1,'foreground')), 1)
check('resume-catchup-coalescing scenario 4', solve('resume-catchup-coalescing', (True,True,3,5,9,True,0,'foreground')), 0)
check('resume-catchup-coalescing scenario 5', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'background')), 1)
check('resume-catchup-coalescing scenario 6', solve('resume-catchup-coalescing', (True,True,3,12,9,False,0,'foreground')), 0)
check('next-tick-from-now scenario 1', solve('next-tick-from-now', (True,True,N+2,5,5,False,3,'foreground')), N+7)
check('next-tick-from-now scenario 2', solve('next-tick-from-now', (False,True,3,5,9,False,2,'foreground')), 12)
check('next-tick-from-now scenario 3', solve('next-tick-from-now', (True,False,3,5,9,False,1,'foreground')), 12)
check('next-tick-from-now scenario 4', solve('next-tick-from-now', (True,True,3,5,9,True,0,'foreground')), 12)
check('next-tick-from-now scenario 5', solve('next-tick-from-now', (False,True,3,5,9,False,2,'background')), 12)
check('next-tick-from-now scenario 6', solve('next-tick-from-now', (True,True,3,12,9,False,0,'foreground')), 12)
check('remaining-delay-clamp scenario 1', solve('remaining-delay-clamp', (True,True,N+2,5,5,False,3,'foreground')), 0)
check('remaining-delay-clamp scenario 2', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'foreground')), 0)
check('remaining-delay-clamp scenario 3', solve('remaining-delay-clamp', (True,False,3,5,9,False,1,'foreground')), 0)
check('remaining-delay-clamp scenario 4', solve('remaining-delay-clamp', (True,True,3,5,9,True,0,'foreground')), 0)
check('remaining-delay-clamp scenario 5', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'background')), 0)
check('remaining-delay-clamp scenario 6', solve('remaining-delay-clamp', (True,True,3,12,9,False,0,'foreground')), 3)
check('offline-poll-reason scenario 1', solve('offline-poll-reason', (True,True,N+2,5,5,False,3,'foreground')), None)
check('offline-poll-reason scenario 2', solve('offline-poll-reason', (False,True,3,5,9,False,2,'foreground')), 'hidden')
check('offline-poll-reason scenario 3', solve('offline-poll-reason', (True,False,3,5,9,False,1,'foreground')), 'offline')
check('offline-poll-reason scenario 4', solve('offline-poll-reason', (True,True,3,5,9,True,0,'foreground')), None)
check('offline-poll-reason scenario 5', solve('offline-poll-reason', (False,True,3,5,9,False,2,'background')), None)
check('offline-poll-reason scenario 6', solve('offline-poll-reason', (True,True,3,12,9,False,0,'foreground')), None)
check('inflight-reconnect-dedup scenario 1', solve('inflight-reconnect-dedup', (True,True,N+2,5,5,False,3,'foreground')), True)
check('inflight-reconnect-dedup scenario 2', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'foreground')), True)
check('inflight-reconnect-dedup scenario 3', solve('inflight-reconnect-dedup', (True,False,3,5,9,False,1,'foreground')), False)
check('inflight-reconnect-dedup scenario 4', solve('inflight-reconnect-dedup', (True,True,3,5,9,True,0,'foreground')), False)
check('inflight-reconnect-dedup scenario 5', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'background')), True)
check('inflight-reconnect-dedup scenario 6', solve('inflight-reconnect-dedup', (True,True,3,12,9,False,0,'foreground')), False)
check('hidden-backlog-cap scenario 1', solve('hidden-backlog-cap', (True,True,N+2,5,5,False,3,'foreground')), 3)
check('hidden-backlog-cap scenario 2', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'foreground')), 1)
check('hidden-backlog-cap scenario 3', solve('hidden-backlog-cap', (True,False,3,5,9,False,1,'foreground')), 1)
check('hidden-backlog-cap scenario 4', solve('hidden-backlog-cap', (True,True,3,5,9,True,0,'foreground')), 0)
check('hidden-backlog-cap scenario 5', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'background')), 1)
check('hidden-backlog-cap scenario 6', solve('hidden-backlog-cap', (True,True,3,12,9,False,0,'foreground')), 0)
check('background-policy-override scenario 1', solve('background-policy-override', (True,True,N+2,5,5,False,3,'foreground')), True)
check('background-policy-override scenario 2', solve('background-policy-override', (False,True,3,5,9,False,2,'foreground')), False)
check('background-policy-override scenario 3', solve('background-policy-override', (True,False,3,5,9,False,1,'foreground')), True)
check('background-policy-override scenario 4', solve('background-policy-override', (True,True,3,5,9,True,0,'foreground')), True)
check('background-policy-override scenario 5', solve('background-policy-override', (False,True,3,5,9,False,2,'background')), True)
check('background-policy-override scenario 6', solve('background-policy-override', (True,True,3,12,9,False,0,'foreground')), True)
check('timer-install-when-online scenario 1', solve('timer-install-when-online', (True,True,N+2,5,5,False,3,'foreground')), N+2)
check('timer-install-when-online scenario 2', solve('timer-install-when-online', (False,True,3,5,9,False,2,'foreground')), None)
check('timer-install-when-online scenario 3', solve('timer-install-when-online', (True,False,3,5,9,False,1,'foreground')), None)
check('timer-install-when-online scenario 4', solve('timer-install-when-online', (True,True,3,5,9,True,0,'foreground')), 3)
check('timer-install-when-online scenario 5', solve('timer-install-when-online', (False,True,3,5,9,False,2,'background')), 3)
check('timer-install-when-online scenario 6', solve('timer-install-when-online', (True,True,3,12,9,False,0,'foreground')), 3)
check('poll-transition-state scenario 1', solve('poll-transition-state', (True,True,N+2,5,5,False,3,'foreground')), 'waiting')
check('poll-transition-state scenario 2', solve('poll-transition-state', (False,True,3,5,9,False,2,'foreground')), 'paused')
check('poll-transition-state scenario 3', solve('poll-transition-state', (True,False,3,5,9,False,1,'foreground')), 'paused')
check('poll-transition-state scenario 4', solve('poll-transition-state', (True,True,3,5,9,True,0,'foreground')), 'running')
check('poll-transition-state scenario 5', solve('poll-transition-state', (False,True,3,5,9,False,2,'background')), 'waiting')
check('poll-transition-state scenario 6', solve('poll-transition-state', (True,True,3,12,9,False,0,'foreground')), 'waiting')
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:
Resume catchup coalescing.

Only one poll may be in flight. Foreground polling pauses offline or hidden; a background policy permits hidden work. Missed ticks coalesce into one catch-up request and scheduling restarts relative to the current clock. Operation resume-catchup-coalescing has the six explicit input/output oracles below.

split: open-access


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

N = 1
observations = []
def solve(operation, s):
    visible, online, interval, due, now, in_flight, queued, policy = s
    if operation == 'foreground-tick-admission':
        return online and (visible or policy=='background') and not in_flight and now>=due
    if operation == 'resume-catchup-coalescing':
        return int(queued>0)
    if operation == 'next-tick-from-now':
        return due+interval
    if operation == 'remaining-delay-clamp':
        return max(0,due-now)
    if operation == 'offline-poll-reason':
        return 'offline' if not online else ('hidden' if not visible and policy!='background' else None)
    if operation == 'inflight-reconnect-dedup':
        return online and not in_flight and queued>0
    if operation == 'hidden-backlog-cap':
        return min(queued,1) if not visible else queued
    if operation == 'background-policy-override':
        return visible or policy=='background'
    if operation == 'timer-install-when-online':
        return interval if online and (visible or policy=='background') else None
    if operation == 'poll-transition-state':
        return 'running' if in_flight else ('waiting' if online and (visible or policy=='background') else 'paused')
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('foreground-tick-admission scenario 1', solve('foreground-tick-admission', (True,True,N+2,5,5,False,3,'foreground')), True)
check('foreground-tick-admission scenario 2', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'foreground')), False)
check('foreground-tick-admission scenario 3', solve('foreground-tick-admission', (True,False,3,5,9,False,1,'foreground')), False)
check('foreground-tick-admission scenario 4', solve('foreground-tick-admission', (True,True,3,5,9,True,0,'foreground')), False)
check('foreground-tick-admission scenario 5', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'background')), True)
check('foreground-tick-admission scenario 6', solve('foreground-tick-admission', (True,True,3,12,9,False,0,'foreground')), False)
check('resume-catchup-coalescing scenario 1', solve('resume-catchup-coalescing', (True,True,N+2,5,5,False,3,'foreground')), 1)
check('resume-catchup-coalescing scenario 2', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'foreground')), 1)
check('resume-catchup-coalescing scenario 3', solve('resume-catchup-coalescing', (True,False,3,5,9,False,1,'foreground')), 1)
check('resume-catchup-coalescing scenario 4', solve('resume-catchup-coalescing', (True,True,3,5,9,True,0,'foreground')), 0)
check('resume-catchup-coalescing scenario 5', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'background')), 1)
check('resume-catchup-coalescing scenario 6', solve('resume-catchup-coalescing', (True,True,3,12,9,False,0,'foreground')), 0)
check('next-tick-from-now scenario 1', solve('next-tick-from-now', (True,True,N+2,5,5,False,3,'foreground')), N+7)
check('next-tick-from-now scenario 2', solve('next-tick-from-now', (False,True,3,5,9,False,2,'foreground')), 12)
check('next-tick-from-now scenario 3', solve('next-tick-from-now', (True,False,3,5,9,False,1,'foreground')), 12)
check('next-tick-from-now scenario 4', solve('next-tick-from-now', (True,True,3,5,9,True,0,'foreground')), 12)
check('next-tick-from-now scenario 5', solve('next-tick-from-now', (False,True,3,5,9,False,2,'background')), 12)
check('next-tick-from-now scenario 6', solve('next-tick-from-now', (True,True,3,12,9,False,0,'foreground')), 12)
check('remaining-delay-clamp scenario 1', solve('remaining-delay-clamp', (True,True,N+2,5,5,False,3,'foreground')), 0)
check('remaining-delay-clamp scenario 2', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'foreground')), 0)
check('remaining-delay-clamp scenario 3', solve('remaining-delay-clamp', (True,False,3,5,9,False,1,'foreground')), 0)
check('remaining-delay-clamp scenario 4', solve('remaining-delay-clamp', (True,True,3,5,9,True,0,'foreground')), 0)
check('remaining-delay-clamp scenario 5', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'background')), 0)
check('remaining-delay-clamp scenario 6', solve('remaining-delay-clamp', (True,True,3,12,9,False,0,'foreground')), 3)
check('offline-poll-reason scenario 1', solve('offline-poll-reason', (True,True,N+2,5,5,False,3,'foreground')), None)
check('offline-poll-reason scenario 2', solve('offline-poll-reason', (False,True,3,5,9,False,2,'foreground')), 'hidden')
check('offline-poll-reason scenario 3', solve('offline-poll-reason', (True,False,3,5,9,False,1,'foreground')), 'offline')
check('offline-poll-reason scenario 4', solve('offline-poll-reason', (True,True,3,5,9,True,0,'foreground')), None)
check('offline-poll-reason scenario 5', solve('offline-poll-reason', (False,True,3,5,9,False,2,'background')), None)
check('offline-poll-reason scenario 6', solve('offline-poll-reason', (True,True,3,12,9,False,0,'foreground')), None)
check('inflight-reconnect-dedup scenario 1', solve('inflight-reconnect-dedup', (True,True,N+2,5,5,False,3,'foreground')), True)
check('inflight-reconnect-dedup scenario 2', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'foreground')), True)
check('inflight-reconnect-dedup scenario 3', solve('inflight-reconnect-dedup', (True,False,3,5,9,False,1,'foreground')), False)
check('inflight-reconnect-dedup scenario 4', solve('inflight-reconnect-dedup', (True,True,3,5,9,True,0,'foreground')), False)
check('inflight-reconnect-dedup scenario 5', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'background')), True)
check('inflight-reconnect-dedup scenario 6', solve('inflight-reconnect-dedup', (True,True,3,12,9,False,0,'foreground')), False)
check('hidden-backlog-cap scenario 1', solve('hidden-backlog-cap', (True,True,N+2,5,5,False,3,'foreground')), 3)
check('hidden-backlog-cap scenario 2', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'foreground')), 1)
check('hidden-backlog-cap scenario 3', solve('hidden-backlog-cap', (True,False,3,5,9,False,1,'foreground')), 1)
check('hidden-backlog-cap scenario 4', solve('hidden-backlog-cap', (True,True,3,5,9,True,0,'foreground')), 0)
check('hidden-backlog-cap scenario 5', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'background')), 1)
check('hidden-backlog-cap scenario 6', solve('hidden-backlog-cap', (True,True,3,12,9,False,0,'foreground')), 0)
check('background-policy-override scenario 1', solve('background-policy-override', (True,True,N+2,5,5,False,3,'foreground')), True)
check('background-policy-override scenario 2', solve('background-policy-override', (False,True,3,5,9,False,2,'foreground')), False)
check('background-policy-override scenario 3', solve('background-policy-override', (True,False,3,5,9,False,1,'foreground')), True)
check('background-policy-override scenario 4', solve('background-policy-override', (True,True,3,5,9,True,0,'foreground')), True)
check('background-policy-override scenario 5', solve('background-policy-override', (False,True,3,5,9,False,2,'background')), True)
check('background-policy-override scenario 6', solve('background-policy-override', (True,True,3,12,9,False,0,'foreground')), True)
check('timer-install-when-online scenario 1', solve('timer-install-when-online', (True,True,N+2,5,5,False,3,'foreground')), N+2)
check('timer-install-when-online scenario 2', solve('timer-install-when-online', (False,True,3,5,9,False,2,'foreground')), None)
check('timer-install-when-online scenario 3', solve('timer-install-when-online', (True,False,3,5,9,False,1,'foreground')), None)
check('timer-install-when-online scenario 4', solve('timer-install-when-online', (True,True,3,5,9,True,0,'foreground')), 3)
check('timer-install-when-online scenario 5', solve('timer-install-when-online', (False,True,3,5,9,False,2,'background')), 3)
check('timer-install-when-online scenario 6', solve('timer-install-when-online', (True,True,3,12,9,False,0,'foreground')), 3)
check('poll-transition-state scenario 1', solve('poll-transition-state', (True,True,N+2,5,5,False,3,'foreground')), 'waiting')
check('poll-transition-state scenario 2', solve('poll-transition-state', (False,True,3,5,9,False,2,'foreground')), 'paused')
check('poll-transition-state scenario 3', solve('poll-transition-state', (True,False,3,5,9,False,1,'foreground')), 'paused')
check('poll-transition-state scenario 4', solve('poll-transition-state', (True,True,3,5,9,True,0,'foreground')), 'running')
check('poll-transition-state scenario 5', solve('poll-transition-state', (False,True,3,5,9,False,2,'background')), 'waiting')
check('poll-transition-state scenario 6', solve('poll-transition-state', (True,True,3,12,9,False,0,'foreground')), 'waiting')
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(operation, s):
    visible, online, interval, due, now, in_flight, queued, policy = s
    if operation == 'foreground-tick-admission':
        return online and (visible or policy=='background') and not in_flight and now>=due
    if operation == 'resume-catchup-coalescing':
        return int(queued>0)
    if operation == 'next-tick-from-now':
        return now
    if operation == 'remaining-delay-clamp':
        return max(0,due-now)
    if operation == 'offline-poll-reason':
        return 'offline' if not online else ('hidden' if not visible and policy!='background' else None)
    if operation == 'inflight-reconnect-dedup':
        return online and not in_flight and queued>0
    if operation == 'hidden-backlog-cap':
        return min(queued,1) if not visible else queued
    if operation == 'background-policy-override':
        return visible or policy=='background'
    if operation == 'timer-install-when-online':
        return interval if online and (visible or policy=='background') else None
    if operation == 'poll-transition-state':
        return 'running' if in_flight else ('waiting' if online and (visible or policy=='background') else 'paused')
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('foreground-tick-admission scenario 1', solve('foreground-tick-admission', (True,True,N+2,5,5,False,3,'foreground')), True)
check('foreground-tick-admission scenario 2', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'foreground')), False)
check('foreground-tick-admission scenario 3', solve('foreground-tick-admission', (True,False,3,5,9,False,1,'foreground')), False)
check('foreground-tick-admission scenario 4', solve('foreground-tick-admission', (True,True,3,5,9,True,0,'foreground')), False)
check('foreground-tick-admission scenario 5', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'background')), True)
check('foreground-tick-admission scenario 6', solve('foreground-tick-admission', (True,True,3,12,9,False,0,'foreground')), False)
check('resume-catchup-coalescing scenario 1', solve('resume-catchup-coalescing', (True,True,N+2,5,5,False,3,'foreground')), 1)
check('resume-catchup-coalescing scenario 2', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'foreground')), 1)
check('resume-catchup-coalescing scenario 3', solve('resume-catchup-coalescing', (True,False,3,5,9,False,1,'foreground')), 1)
check('resume-catchup-coalescing scenario 4', solve('resume-catchup-coalescing', (True,True,3,5,9,True,0,'foreground')), 0)
check('resume-catchup-coalescing scenario 5', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'background')), 1)
check('resume-catchup-coalescing scenario 6', solve('resume-catchup-coalescing', (True,True,3,12,9,False,0,'foreground')), 0)
check('next-tick-from-now scenario 1', solve('next-tick-from-now', (True,True,N+2,5,5,False,3,'foreground')), N+7)
check('next-tick-from-now scenario 2', solve('next-tick-from-now', (False,True,3,5,9,False,2,'foreground')), 12)
check('next-tick-from-now scenario 3', solve('next-tick-from-now', (True,False,3,5,9,False,1,'foreground')), 12)
check('next-tick-from-now scenario 4', solve('next-tick-from-now', (True,True,3,5,9,True,0,'foreground')), 12)
check('next-tick-from-now scenario 5', solve('next-tick-from-now', (False,True,3,5,9,False,2,'background')), 12)
check('next-tick-from-now scenario 6', solve('next-tick-from-now', (True,True,3,12,9,False,0,'foreground')), 12)
check('remaining-delay-clamp scenario 1', solve('remaining-delay-clamp', (True,True,N+2,5,5,False,3,'foreground')), 0)
check('remaining-delay-clamp scenario 2', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'foreground')), 0)
check('remaining-delay-clamp scenario 3', solve('remaining-delay-clamp', (True,False,3,5,9,False,1,'foreground')), 0)
check('remaining-delay-clamp scenario 4', solve('remaining-delay-clamp', (True,True,3,5,9,True,0,'foreground')), 0)
check('remaining-delay-clamp scenario 5', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'background')), 0)
check('remaining-delay-clamp scenario 6', solve('remaining-delay-clamp', (True,True,3,12,9,False,0,'foreground')), 3)
check('offline-poll-reason scenario 1', solve('offline-poll-reason', (True,True,N+2,5,5,False,3,'foreground')), None)
check('offline-poll-reason scenario 2', solve('offline-poll-reason', (False,True,3,5,9,False,2,'foreground')), 'hidden')
check('offline-poll-reason scenario 3', solve('offline-poll-reason', (True,False,3,5,9,False,1,'foreground')), 'offline')
check('offline-poll-reason scenario 4', solve('offline-poll-reason', (True,True,3,5,9,True,0,'foreground')), None)
check('offline-poll-reason scenario 5', solve('offline-poll-reason', (False,True,3,5,9,False,2,'background')), None)
check('offline-poll-reason scenario 6', solve('offline-poll-reason', (True,True,3,12,9,False,0,'foreground')), None)
check('inflight-reconnect-dedup scenario 1', solve('inflight-reconnect-dedup', (True,True,N+2,5,5,False,3,'foreground')), True)
check('inflight-reconnect-dedup scenario 2', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'foreground')), True)
check('inflight-reconnect-dedup scenario 3', solve('inflight-reconnect-dedup', (True,False,3,5,9,False,1,'foreground')), False)
check('inflight-reconnect-dedup scenario 4', solve('inflight-reconnect-dedup', (True,True,3,5,9,True,0,'foreground')), False)
check('inflight-reconnect-dedup scenario 5', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'background')), True)
check('inflight-reconnect-dedup scenario 6', solve('inflight-reconnect-dedup', (True,True,3,12,9,False,0,'foreground')), False)
check('hidden-backlog-cap scenario 1', solve('hidden-backlog-cap', (True,True,N+2,5,5,False,3,'foreground')), 3)
check('hidden-backlog-cap scenario 2', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'foreground')), 1)
check('hidden-backlog-cap scenario 3', solve('hidden-backlog-cap', (True,False,3,5,9,False,1,'foreground')), 1)
check('hidden-backlog-cap scenario 4', solve('hidden-backlog-cap', (True,True,3,5,9,True,0,'foreground')), 0)
check('hidden-backlog-cap scenario 5', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'background')), 1)
check('hidden-backlog-cap scenario 6', solve('hidden-backlog-cap', (True,True,3,12,9,False,0,'foreground')), 0)
check('background-policy-override scenario 1', solve('background-policy-override', (True,True,N+2,5,5,False,3,'foreground')), True)
check('background-policy-override scenario 2', solve('background-policy-override', (False,True,3,5,9,False,2,'foreground')), False)
check('background-policy-override scenario 3', solve('background-policy-override', (True,False,3,5,9,False,1,'foreground')), True)
check('background-policy-override scenario 4', solve('background-policy-override', (True,True,3,5,9,True,0,'foreground')), True)
check('background-policy-override scenario 5', solve('background-policy-override', (False,True,3,5,9,False,2,'background')), True)
check('background-policy-override scenario 6', solve('background-policy-override', (True,True,3,12,9,False,0,'foreground')), True)
check('timer-install-when-online scenario 1', solve('timer-install-when-online', (True,True,N+2,5,5,False,3,'foreground')), N+2)
check('timer-install-when-online scenario 2', solve('timer-install-when-online', (False,True,3,5,9,False,2,'foreground')), None)
check('timer-install-when-online scenario 3', solve('timer-install-when-online', (True,False,3,5,9,False,1,'foreground')), None)
check('timer-install-when-online scenario 4', solve('timer-install-when-online', (True,True,3,5,9,True,0,'foreground')), 3)
check('timer-install-when-online scenario 5', solve('timer-install-when-online', (False,True,3,5,9,False,2,'background')), 3)
check('timer-install-when-online scenario 6', solve('timer-install-when-online', (True,True,3,12,9,False,0,'foreground')), 3)
check('poll-transition-state scenario 1', solve('poll-transition-state', (True,True,N+2,5,5,False,3,'foreground')), 'waiting')
check('poll-transition-state scenario 2', solve('poll-transition-state', (False,True,3,5,9,False,2,'foreground')), 'paused')
check('poll-transition-state scenario 3', solve('poll-transition-state', (True,False,3,5,9,False,1,'foreground')), 'paused')
check('poll-transition-state scenario 4', solve('poll-transition-state', (True,True,3,5,9,True,0,'foreground')), 'running')
check('poll-transition-state scenario 5', solve('poll-transition-state', (False,True,3,5,9,False,2,'background')), 'waiting')
check('poll-transition-state scenario 6', solve('poll-transition-state', (True,True,3,12,9,False,0,'foreground')), 'waiting')
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:
Next tick from now.

Only one poll may be in flight. Foreground polling pauses offline or hidden; a background policy permits hidden work. Missed ticks coalesce into one catch-up request and scheduling restarts relative to the current clock. Operation next-tick-from-now has the six explicit input/output oracles below.

split: open-access


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

N = 1
observations = []
def solve(operation, s):
    visible, online, interval, due, now, in_flight, queued, policy = s
    if operation == 'foreground-tick-admission':
        return online and (visible or policy=='background') and not in_flight and now>=due
    if operation == 'resume-catchup-coalescing':
        return int(queued>0)
    if operation == 'next-tick-from-now':
        return now+interval
    if operation == 'remaining-delay-clamp':
        return due-now
    if operation == 'offline-poll-reason':
        return 'offline' if not online else ('hidden' if not visible and policy!='background' else None)
    if operation == 'inflight-reconnect-dedup':
        return online and not in_flight and queued>0
    if operation == 'hidden-backlog-cap':
        return min(queued,1) if not visible else queued
    if operation == 'background-policy-override':
        return visible or policy=='background'
    if operation == 'timer-install-when-online':
        return interval if online and (visible or policy=='background') else None
    if operation == 'poll-transition-state':
        return 'running' if in_flight else ('waiting' if online and (visible or policy=='background') else 'paused')
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('foreground-tick-admission scenario 1', solve('foreground-tick-admission', (True,True,N+2,5,5,False,3,'foreground')), True)
check('foreground-tick-admission scenario 2', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'foreground')), False)
check('foreground-tick-admission scenario 3', solve('foreground-tick-admission', (True,False,3,5,9,False,1,'foreground')), False)
check('foreground-tick-admission scenario 4', solve('foreground-tick-admission', (True,True,3,5,9,True,0,'foreground')), False)
check('foreground-tick-admission scenario 5', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'background')), True)
check('foreground-tick-admission scenario 6', solve('foreground-tick-admission', (True,True,3,12,9,False,0,'foreground')), False)
check('resume-catchup-coalescing scenario 1', solve('resume-catchup-coalescing', (True,True,N+2,5,5,False,3,'foreground')), 1)
check('resume-catchup-coalescing scenario 2', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'foreground')), 1)
check('resume-catchup-coalescing scenario 3', solve('resume-catchup-coalescing', (True,False,3,5,9,False,1,'foreground')), 1)
check('resume-catchup-coalescing scenario 4', solve('resume-catchup-coalescing', (True,True,3,5,9,True,0,'foreground')), 0)
check('resume-catchup-coalescing scenario 5', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'background')), 1)
check('resume-catchup-coalescing scenario 6', solve('resume-catchup-coalescing', (True,True,3,12,9,False,0,'foreground')), 0)
check('next-tick-from-now scenario 1', solve('next-tick-from-now', (True,True,N+2,5,5,False,3,'foreground')), N+7)
check('next-tick-from-now scenario 2', solve('next-tick-from-now', (False,True,3,5,9,False,2,'foreground')), 12)
check('next-tick-from-now scenario 3', solve('next-tick-from-now', (True,False,3,5,9,False,1,'foreground')), 12)
check('next-tick-from-now scenario 4', solve('next-tick-from-now', (True,True,3,5,9,True,0,'foreground')), 12)
check('next-tick-from-now scenario 5', solve('next-tick-from-now', (False,True,3,5,9,False,2,'background')), 12)
check('next-tick-from-now scenario 6', solve('next-tick-from-now', (True,True,3,12,9,False,0,'foreground')), 12)
check('remaining-delay-clamp scenario 1', solve('remaining-delay-clamp', (True,True,N+2,5,5,False,3,'foreground')), 0)
check('remaining-delay-clamp scenario 2', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'foreground')), 0)
check('remaining-delay-clamp scenario 3', solve('remaining-delay-clamp', (True,False,3,5,9,False,1,'foreground')), 0)
check('remaining-delay-clamp scenario 4', solve('remaining-delay-clamp', (True,True,3,5,9,True,0,'foreground')), 0)
check('remaining-delay-clamp scenario 5', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'background')), 0)
check('remaining-delay-clamp scenario 6', solve('remaining-delay-clamp', (True,True,3,12,9,False,0,'foreground')), 3)
check('offline-poll-reason scenario 1', solve('offline-poll-reason', (True,True,N+2,5,5,False,3,'foreground')), None)
check('offline-poll-reason scenario 2', solve('offline-poll-reason', (False,True,3,5,9,False,2,'foreground')), 'hidden')
check('offline-poll-reason scenario 3', solve('offline-poll-reason', (True,False,3,5,9,False,1,'foreground')), 'offline')
check('offline-poll-reason scenario 4', solve('offline-poll-reason', (True,True,3,5,9,True,0,'foreground')), None)
check('offline-poll-reason scenario 5', solve('offline-poll-reason', (False,True,3,5,9,False,2,'background')), None)
check('offline-poll-reason scenario 6', solve('offline-poll-reason', (True,True,3,12,9,False,0,'foreground')), None)
check('inflight-reconnect-dedup scenario 1', solve('inflight-reconnect-dedup', (True,True,N+2,5,5,False,3,'foreground')), True)
check('inflight-reconnect-dedup scenario 2', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'foreground')), True)
check('inflight-reconnect-dedup scenario 3', solve('inflight-reconnect-dedup', (True,False,3,5,9,False,1,'foreground')), False)
check('inflight-reconnect-dedup scenario 4', solve('inflight-reconnect-dedup', (True,True,3,5,9,True,0,'foreground')), False)
check('inflight-reconnect-dedup scenario 5', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'background')), True)
check('inflight-reconnect-dedup scenario 6', solve('inflight-reconnect-dedup', (True,True,3,12,9,False,0,'foreground')), False)
check('hidden-backlog-cap scenario 1', solve('hidden-backlog-cap', (True,True,N+2,5,5,False,3,'foreground')), 3)
check('hidden-backlog-cap scenario 2', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'foreground')), 1)
check('hidden-backlog-cap scenario 3', solve('hidden-backlog-cap', (True,False,3,5,9,False,1,'foreground')), 1)
check('hidden-backlog-cap scenario 4', solve('hidden-backlog-cap', (True,True,3,5,9,True,0,'foreground')), 0)
check('hidden-backlog-cap scenario 5', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'background')), 1)
check('hidden-backlog-cap scenario 6', solve('hidden-backlog-cap', (True,True,3,12,9,False,0,'foreground')), 0)
check('background-policy-override scenario 1', solve('background-policy-override', (True,True,N+2,5,5,False,3,'foreground')), True)
check('background-policy-override scenario 2', solve('background-policy-override', (False,True,3,5,9,False,2,'foreground')), False)
check('background-policy-override scenario 3', solve('background-policy-override', (True,False,3,5,9,False,1,'foreground')), True)
check('background-policy-override scenario 4', solve('background-policy-override', (True,True,3,5,9,True,0,'foreground')), True)
check('background-policy-override scenario 5', solve('background-policy-override', (False,True,3,5,9,False,2,'background')), True)
check('background-policy-override scenario 6', solve('background-policy-override', (True,True,3,12,9,False,0,'foreground')), True)
check('timer-install-when-online scenario 1', solve('timer-install-when-online', (True,True,N+2,5,5,False,3,'foreground')), N+2)
check('timer-install-when-online scenario 2', solve('timer-install-when-online', (False,True,3,5,9,False,2,'foreground')), None)
check('timer-install-when-online scenario 3', solve('timer-install-when-online', (True,False,3,5,9,False,1,'foreground')), None)
check('timer-install-when-online scenario 4', solve('timer-install-when-online', (True,True,3,5,9,True,0,'foreground')), 3)
check('timer-install-when-online scenario 5', solve('timer-install-when-online', (False,True,3,5,9,False,2,'background')), 3)
check('timer-install-when-online scenario 6', solve('timer-install-when-online', (True,True,3,12,9,False,0,'foreground')), 3)
check('poll-transition-state scenario 1', solve('poll-transition-state', (True,True,N+2,5,5,False,3,'foreground')), 'waiting')
check('poll-transition-state scenario 2', solve('poll-transition-state', (False,True,3,5,9,False,2,'foreground')), 'paused')
check('poll-transition-state scenario 3', solve('poll-transition-state', (True,False,3,5,9,False,1,'foreground')), 'paused')
check('poll-transition-state scenario 4', solve('poll-transition-state', (True,True,3,5,9,True,0,'foreground')), 'running')
check('poll-transition-state scenario 5', solve('poll-transition-state', (False,True,3,5,9,False,2,'background')), 'waiting')
check('poll-transition-state scenario 6', solve('poll-transition-state', (True,True,3,12,9,False,0,'foreground')), 'waiting')
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(operation, s):
    visible, online, interval, due, now, in_flight, queued, policy = s
    if operation == 'foreground-tick-admission':
        return online and (visible or policy=='background') and not in_flight and now>=due
    if operation == 'resume-catchup-coalescing':
        return int(queued>0)
    if operation == 'next-tick-from-now':
        return now+interval
    if operation == 'remaining-delay-clamp':
        return abs(due-now)
    if operation == 'offline-poll-reason':
        return 'offline' if not online else ('hidden' if not visible and policy!='background' else None)
    if operation == 'inflight-reconnect-dedup':
        return online and not in_flight and queued>0
    if operation == 'hidden-backlog-cap':
        return min(queued,1) if not visible else queued
    if operation == 'background-policy-override':
        return visible or policy=='background'
    if operation == 'timer-install-when-online':
        return interval if online and (visible or policy=='background') else None
    if operation == 'poll-transition-state':
        return 'running' if in_flight else ('waiting' if online and (visible or policy=='background') else 'paused')
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('foreground-tick-admission scenario 1', solve('foreground-tick-admission', (True,True,N+2,5,5,False,3,'foreground')), True)
check('foreground-tick-admission scenario 2', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'foreground')), False)
check('foreground-tick-admission scenario 3', solve('foreground-tick-admission', (True,False,3,5,9,False,1,'foreground')), False)
check('foreground-tick-admission scenario 4', solve('foreground-tick-admission', (True,True,3,5,9,True,0,'foreground')), False)
check('foreground-tick-admission scenario 5', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'background')), True)
check('foreground-tick-admission scenario 6', solve('foreground-tick-admission', (True,True,3,12,9,False,0,'foreground')), False)
check('resume-catchup-coalescing scenario 1', solve('resume-catchup-coalescing', (True,True,N+2,5,5,False,3,'foreground')), 1)
check('resume-catchup-coalescing scenario 2', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'foreground')), 1)
check('resume-catchup-coalescing scenario 3', solve('resume-catchup-coalescing', (True,False,3,5,9,False,1,'foreground')), 1)
check('resume-catchup-coalescing scenario 4', solve('resume-catchup-coalescing', (True,True,3,5,9,True,0,'foreground')), 0)
check('resume-catchup-coalescing scenario 5', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'background')), 1)
check('resume-catchup-coalescing scenario 6', solve('resume-catchup-coalescing', (True,True,3,12,9,False,0,'foreground')), 0)
check('next-tick-from-now scenario 1', solve('next-tick-from-now', (True,True,N+2,5,5,False,3,'foreground')), N+7)
check('next-tick-from-now scenario 2', solve('next-tick-from-now', (False,True,3,5,9,False,2,'foreground')), 12)
check('next-tick-from-now scenario 3', solve('next-tick-from-now', (True,False,3,5,9,False,1,'foreground')), 12)
check('next-tick-from-now scenario 4', solve('next-tick-from-now', (True,True,3,5,9,True,0,'foreground')), 12)
check('next-tick-from-now scenario 5', solve('next-tick-from-now', (False,True,3,5,9,False,2,'background')), 12)
check('next-tick-from-now scenario 6', solve('next-tick-from-now', (True,True,3,12,9,False,0,'foreground')), 12)
check('remaining-delay-clamp scenario 1', solve('remaining-delay-clamp', (True,True,N+2,5,5,False,3,'foreground')), 0)
check('remaining-delay-clamp scenario 2', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'foreground')), 0)
check('remaining-delay-clamp scenario 3', solve('remaining-delay-clamp', (True,False,3,5,9,False,1,'foreground')), 0)
check('remaining-delay-clamp scenario 4', solve('remaining-delay-clamp', (True,True,3,5,9,True,0,'foreground')), 0)
check('remaining-delay-clamp scenario 5', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'background')), 0)
check('remaining-delay-clamp scenario 6', solve('remaining-delay-clamp', (True,True,3,12,9,False,0,'foreground')), 3)
check('offline-poll-reason scenario 1', solve('offline-poll-reason', (True,True,N+2,5,5,False,3,'foreground')), None)
check('offline-poll-reason scenario 2', solve('offline-poll-reason', (False,True,3,5,9,False,2,'foreground')), 'hidden')
check('offline-poll-reason scenario 3', solve('offline-poll-reason', (True,False,3,5,9,False,1,'foreground')), 'offline')
check('offline-poll-reason scenario 4', solve('offline-poll-reason', (True,True,3,5,9,True,0,'foreground')), None)
check('offline-poll-reason scenario 5', solve('offline-poll-reason', (False,True,3,5,9,False,2,'background')), None)
check('offline-poll-reason scenario 6', solve('offline-poll-reason', (True,True,3,12,9,False,0,'foreground')), None)
check('inflight-reconnect-dedup scenario 1', solve('inflight-reconnect-dedup', (True,True,N+2,5,5,False,3,'foreground')), True)
check('inflight-reconnect-dedup scenario 2', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'foreground')), True)
check('inflight-reconnect-dedup scenario 3', solve('inflight-reconnect-dedup', (True,False,3,5,9,False,1,'foreground')), False)
check('inflight-reconnect-dedup scenario 4', solve('inflight-reconnect-dedup', (True,True,3,5,9,True,0,'foreground')), False)
check('inflight-reconnect-dedup scenario 5', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'background')), True)
check('inflight-reconnect-dedup scenario 6', solve('inflight-reconnect-dedup', (True,True,3,12,9,False,0,'foreground')), False)
check('hidden-backlog-cap scenario 1', solve('hidden-backlog-cap', (True,True,N+2,5,5,False,3,'foreground')), 3)
check('hidden-backlog-cap scenario 2', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'foreground')), 1)
check('hidden-backlog-cap scenario 3', solve('hidden-backlog-cap', (True,False,3,5,9,False,1,'foreground')), 1)
check('hidden-backlog-cap scenario 4', solve('hidden-backlog-cap', (True,True,3,5,9,True,0,'foreground')), 0)
check('hidden-backlog-cap scenario 5', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'background')), 1)
check('hidden-backlog-cap scenario 6', solve('hidden-backlog-cap', (True,True,3,12,9,False,0,'foreground')), 0)
check('background-policy-override scenario 1', solve('background-policy-override', (True,True,N+2,5,5,False,3,'foreground')), True)
check('background-policy-override scenario 2', solve('background-policy-override', (False,True,3,5,9,False,2,'foreground')), False)
check('background-policy-override scenario 3', solve('background-policy-override', (True,False,3,5,9,False,1,'foreground')), True)
check('background-policy-override scenario 4', solve('background-policy-override', (True,True,3,5,9,True,0,'foreground')), True)
check('background-policy-override scenario 5', solve('background-policy-override', (False,True,3,5,9,False,2,'background')), True)
check('background-policy-override scenario 6', solve('background-policy-override', (True,True,3,12,9,False,0,'foreground')), True)
check('timer-install-when-online scenario 1', solve('timer-install-when-online', (True,True,N+2,5,5,False,3,'foreground')), N+2)
check('timer-install-when-online scenario 2', solve('timer-install-when-online', (False,True,3,5,9,False,2,'foreground')), None)
check('timer-install-when-online scenario 3', solve('timer-install-when-online', (True,False,3,5,9,False,1,'foreground')), None)
check('timer-install-when-online scenario 4', solve('timer-install-when-online', (True,True,3,5,9,True,0,'foreground')), 3)
check('timer-install-when-online scenario 5', solve('timer-install-when-online', (False,True,3,5,9,False,2,'background')), 3)
check('timer-install-when-online scenario 6', solve('timer-install-when-online', (True,True,3,12,9,False,0,'foreground')), 3)
check('poll-transition-state scenario 1', solve('poll-transition-state', (True,True,N+2,5,5,False,3,'foreground')), 'waiting')
check('poll-transition-state scenario 2', solve('poll-transition-state', (False,True,3,5,9,False,2,'foreground')), 'paused')
check('poll-transition-state scenario 3', solve('poll-transition-state', (True,False,3,5,9,False,1,'foreground')), 'paused')
check('poll-transition-state scenario 4', solve('poll-transition-state', (True,True,3,5,9,True,0,'foreground')), 'running')
check('poll-transition-state scenario 5', solve('poll-transition-state', (False,True,3,5,9,False,2,'background')), 'waiting')
check('poll-transition-state scenario 6', solve('poll-transition-state', (True,True,3,12,9,False,0,'foreground')), 'waiting')
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:
Remaining delay clamp.

Only one poll may be in flight. Foreground polling pauses offline or hidden; a background policy permits hidden work. Missed ticks coalesce into one catch-up request and scheduling restarts relative to the current clock. Operation remaining-delay-clamp has the six explicit input/output oracles below.

split: open-access


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

N = 1
observations = []
def solve(operation, s):
    visible, online, interval, due, now, in_flight, queued, policy = s
    if operation == 'foreground-tick-admission':
        return online and (visible or policy=='background') and not in_flight and now>=due
    if operation == 'resume-catchup-coalescing':
        return int(queued>0)
    if operation == 'next-tick-from-now':
        return now+interval
    if operation == 'remaining-delay-clamp':
        return max(0,due-now)
    if operation == 'offline-poll-reason':
        return 'hidden' if not visible else None
    if operation == 'inflight-reconnect-dedup':
        return online and not in_flight and queued>0
    if operation == 'hidden-backlog-cap':
        return min(queued,1) if not visible else queued
    if operation == 'background-policy-override':
        return visible or policy=='background'
    if operation == 'timer-install-when-online':
        return interval if online and (visible or policy=='background') else None
    if operation == 'poll-transition-state':
        return 'running' if in_flight else ('waiting' if online and (visible or policy=='background') else 'paused')
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('foreground-tick-admission scenario 1', solve('foreground-tick-admission', (True,True,N+2,5,5,False,3,'foreground')), True)
check('foreground-tick-admission scenario 2', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'foreground')), False)
check('foreground-tick-admission scenario 3', solve('foreground-tick-admission', (True,False,3,5,9,False,1,'foreground')), False)
check('foreground-tick-admission scenario 4', solve('foreground-tick-admission', (True,True,3,5,9,True,0,'foreground')), False)
check('foreground-tick-admission scenario 5', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'background')), True)
check('foreground-tick-admission scenario 6', solve('foreground-tick-admission', (True,True,3,12,9,False,0,'foreground')), False)
check('resume-catchup-coalescing scenario 1', solve('resume-catchup-coalescing', (True,True,N+2,5,5,False,3,'foreground')), 1)
check('resume-catchup-coalescing scenario 2', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'foreground')), 1)
check('resume-catchup-coalescing scenario 3', solve('resume-catchup-coalescing', (True,False,3,5,9,False,1,'foreground')), 1)
check('resume-catchup-coalescing scenario 4', solve('resume-catchup-coalescing', (True,True,3,5,9,True,0,'foreground')), 0)
check('resume-catchup-coalescing scenario 5', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'background')), 1)
check('resume-catchup-coalescing scenario 6', solve('resume-catchup-coalescing', (True,True,3,12,9,False,0,'foreground')), 0)
check('next-tick-from-now scenario 1', solve('next-tick-from-now', (True,True,N+2,5,5,False,3,'foreground')), N+7)
check('next-tick-from-now scenario 2', solve('next-tick-from-now', (False,True,3,5,9,False,2,'foreground')), 12)
check('next-tick-from-now scenario 3', solve('next-tick-from-now', (True,False,3,5,9,False,1,'foreground')), 12)
check('next-tick-from-now scenario 4', solve('next-tick-from-now', (True,True,3,5,9,True,0,'foreground')), 12)
check('next-tick-from-now scenario 5', solve('next-tick-from-now', (False,True,3,5,9,False,2,'background')), 12)
check('next-tick-from-now scenario 6', solve('next-tick-from-now', (True,True,3,12,9,False,0,'foreground')), 12)
check('remaining-delay-clamp scenario 1', solve('remaining-delay-clamp', (True,True,N+2,5,5,False,3,'foreground')), 0)
check('remaining-delay-clamp scenario 2', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'foreground')), 0)
check('remaining-delay-clamp scenario 3', solve('remaining-delay-clamp', (True,False,3,5,9,False,1,'foreground')), 0)
check('remaining-delay-clamp scenario 4', solve('remaining-delay-clamp', (True,True,3,5,9,True,0,'foreground')), 0)
check('remaining-delay-clamp scenario 5', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'background')), 0)
check('remaining-delay-clamp scenario 6', solve('remaining-delay-clamp', (True,True,3,12,9,False,0,'foreground')), 3)
check('offline-poll-reason scenario 1', solve('offline-poll-reason', (True,True,N+2,5,5,False,3,'foreground')), None)
check('offline-poll-reason scenario 2', solve('offline-poll-reason', (False,True,3,5,9,False,2,'foreground')), 'hidden')
check('offline-poll-reason scenario 3', solve('offline-poll-reason', (True,False,3,5,9,False,1,'foreground')), 'offline')
check('offline-poll-reason scenario 4', solve('offline-poll-reason', (True,True,3,5,9,True,0,'foreground')), None)
check('offline-poll-reason scenario 5', solve('offline-poll-reason', (False,True,3,5,9,False,2,'background')), None)
check('offline-poll-reason scenario 6', solve('offline-poll-reason', (True,True,3,12,9,False,0,'foreground')), None)
check('inflight-reconnect-dedup scenario 1', solve('inflight-reconnect-dedup', (True,True,N+2,5,5,False,3,'foreground')), True)
check('inflight-reconnect-dedup scenario 2', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'foreground')), True)
check('inflight-reconnect-dedup scenario 3', solve('inflight-reconnect-dedup', (True,False,3,5,9,False,1,'foreground')), False)
check('inflight-reconnect-dedup scenario 4', solve('inflight-reconnect-dedup', (True,True,3,5,9,True,0,'foreground')), False)
check('inflight-reconnect-dedup scenario 5', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'background')), True)
check('inflight-reconnect-dedup scenario 6', solve('inflight-reconnect-dedup', (True,True,3,12,9,False,0,'foreground')), False)
check('hidden-backlog-cap scenario 1', solve('hidden-backlog-cap', (True,True,N+2,5,5,False,3,'foreground')), 3)
check('hidden-backlog-cap scenario 2', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'foreground')), 1)
check('hidden-backlog-cap scenario 3', solve('hidden-backlog-cap', (True,False,3,5,9,False,1,'foreground')), 1)
check('hidden-backlog-cap scenario 4', solve('hidden-backlog-cap', (True,True,3,5,9,True,0,'foreground')), 0)
check('hidden-backlog-cap scenario 5', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'background')), 1)
check('hidden-backlog-cap scenario 6', solve('hidden-backlog-cap', (True,True,3,12,9,False,0,'foreground')), 0)
check('background-policy-override scenario 1', solve('background-policy-override', (True,True,N+2,5,5,False,3,'foreground')), True)
check('background-policy-override scenario 2', solve('background-policy-override', (False,True,3,5,9,False,2,'foreground')), False)
check('background-policy-override scenario 3', solve('background-policy-override', (True,False,3,5,9,False,1,'foreground')), True)
check('background-policy-override scenario 4', solve('background-policy-override', (True,True,3,5,9,True,0,'foreground')), True)
check('background-policy-override scenario 5', solve('background-policy-override', (False,True,3,5,9,False,2,'background')), True)
check('background-policy-override scenario 6', solve('background-policy-override', (True,True,3,12,9,False,0,'foreground')), True)
check('timer-install-when-online scenario 1', solve('timer-install-when-online', (True,True,N+2,5,5,False,3,'foreground')), N+2)
check('timer-install-when-online scenario 2', solve('timer-install-when-online', (False,True,3,5,9,False,2,'foreground')), None)
check('timer-install-when-online scenario 3', solve('timer-install-when-online', (True,False,3,5,9,False,1,'foreground')), None)
check('timer-install-when-online scenario 4', solve('timer-install-when-online', (True,True,3,5,9,True,0,'foreground')), 3)
check('timer-install-when-online scenario 5', solve('timer-install-when-online', (False,True,3,5,9,False,2,'background')), 3)
check('timer-install-when-online scenario 6', solve('timer-install-when-online', (True,True,3,12,9,False,0,'foreground')), 3)
check('poll-transition-state scenario 1', solve('poll-transition-state', (True,True,N+2,5,5,False,3,'foreground')), 'waiting')
check('poll-transition-state scenario 2', solve('poll-transition-state', (False,True,3,5,9,False,2,'foreground')), 'paused')
check('poll-transition-state scenario 3', solve('poll-transition-state', (True,False,3,5,9,False,1,'foreground')), 'paused')
check('poll-transition-state scenario 4', solve('poll-transition-state', (True,True,3,5,9,True,0,'foreground')), 'running')
check('poll-transition-state scenario 5', solve('poll-transition-state', (False,True,3,5,9,False,2,'background')), 'waiting')
check('poll-transition-state scenario 6', solve('poll-transition-state', (True,True,3,12,9,False,0,'foreground')), 'waiting')
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(operation, s):
    visible, online, interval, due, now, in_flight, queued, policy = s
    if operation == 'foreground-tick-admission':
        return online and (visible or policy=='background') and not in_flight and now>=due
    if operation == 'resume-catchup-coalescing':
        return int(queued>0)
    if operation == 'next-tick-from-now':
        return now+interval
    if operation == 'remaining-delay-clamp':
        return max(0,due-now)
    if operation == 'offline-poll-reason':
        return 'offline' if not online else ('hidden' if not visible else None)
    if operation == 'inflight-reconnect-dedup':
        return online and not in_flight and queued>0
    if operation == 'hidden-backlog-cap':
        return min(queued,1) if not visible else queued
    if operation == 'background-policy-override':
        return visible or policy=='background'
    if operation == 'timer-install-when-online':
        return interval if online and (visible or policy=='background') else None
    if operation == 'poll-transition-state':
        return 'running' if in_flight else ('waiting' if online and (visible or policy=='background') else 'paused')
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('foreground-tick-admission scenario 1', solve('foreground-tick-admission', (True,True,N+2,5,5,False,3,'foreground')), True)
check('foreground-tick-admission scenario 2', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'foreground')), False)
check('foreground-tick-admission scenario 3', solve('foreground-tick-admission', (True,False,3,5,9,False,1,'foreground')), False)
check('foreground-tick-admission scenario 4', solve('foreground-tick-admission', (True,True,3,5,9,True,0,'foreground')), False)
check('foreground-tick-admission scenario 5', solve('foreground-tick-admission', (False,True,3,5,9,False,2,'background')), True)
check('foreground-tick-admission scenario 6', solve('foreground-tick-admission', (True,True,3,12,9,False,0,'foreground')), False)
check('resume-catchup-coalescing scenario 1', solve('resume-catchup-coalescing', (True,True,N+2,5,5,False,3,'foreground')), 1)
check('resume-catchup-coalescing scenario 2', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'foreground')), 1)
check('resume-catchup-coalescing scenario 3', solve('resume-catchup-coalescing', (True,False,3,5,9,False,1,'foreground')), 1)
check('resume-catchup-coalescing scenario 4', solve('resume-catchup-coalescing', (True,True,3,5,9,True,0,'foreground')), 0)
check('resume-catchup-coalescing scenario 5', solve('resume-catchup-coalescing', (False,True,3,5,9,False,2,'background')), 1)
check('resume-catchup-coalescing scenario 6', solve('resume-catchup-coalescing', (True,True,3,12,9,False,0,'foreground')), 0)
check('next-tick-from-now scenario 1', solve('next-tick-from-now', (True,True,N+2,5,5,False,3,'foreground')), N+7)
check('next-tick-from-now scenario 2', solve('next-tick-from-now', (False,True,3,5,9,False,2,'foreground')), 12)
check('next-tick-from-now scenario 3', solve('next-tick-from-now', (True,False,3,5,9,False,1,'foreground')), 12)
check('next-tick-from-now scenario 4', solve('next-tick-from-now', (True,True,3,5,9,True,0,'foreground')), 12)
check('next-tick-from-now scenario 5', solve('next-tick-from-now', (False,True,3,5,9,False,2,'background')), 12)
check('next-tick-from-now scenario 6', solve('next-tick-from-now', (True,True,3,12,9,False,0,'foreground')), 12)
check('remaining-delay-clamp scenario 1', solve('remaining-delay-clamp', (True,True,N+2,5,5,False,3,'foreground')), 0)
check('remaining-delay-clamp scenario 2', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'foreground')), 0)
check('remaining-delay-clamp scenario 3', solve('remaining-delay-clamp', (True,False,3,5,9,False,1,'foreground')), 0)
check('remaining-delay-clamp scenario 4', solve('remaining-delay-clamp', (True,True,3,5,9,True,0,'foreground')), 0)
check('remaining-delay-clamp scenario 5', solve('remaining-delay-clamp', (False,True,3,5,9,False,2,'background')), 0)
check('remaining-delay-clamp scenario 6', solve('remaining-delay-clamp', (True,True,3,12,9,False,0,'foreground')), 3)
check('offline-poll-reason scenario 1', solve('offline-poll-reason', (True,True,N+2,5,5,False,3,'foreground')), None)
check('offline-poll-reason scenario 2', solve('offline-poll-reason', (False,True,3,5,9,False,2,'foreground')), 'hidden')
check('offline-poll-reason scenario 3', solve('offline-poll-reason', (True,False,3,5,9,False,1,'foreground')), 'offline')
check('offline-poll-reason scenario 4', solve('offline-poll-reason', (True,True,3,5,9,True,0,'foreground')), None)
check('offline-poll-reason scenario 5', solve('offline-poll-reason', (False,True,3,5,9,False,2,'background')), None)
check('offline-poll-reason scenario 6', solve('offline-poll-reason', (True,True,3,12,9,False,0,'foreground')), None)
check('inflight-reconnect-dedup scenario 1', solve('inflight-reconnect-dedup', (True,True,N+2,5,5,False,3,'foreground')), True)
check('inflight-reconnect-dedup scenario 2', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'foreground')), True)
check('inflight-reconnect-dedup scenario 3', solve('inflight-reconnect-dedup', (True,False,3,5,9,False,1,'foreground')), False)
check('inflight-reconnect-dedup scenario 4', solve('inflight-reconnect-dedup', (True,True,3,5,9,True,0,'foreground')), False)
check('inflight-reconnect-dedup scenario 5', solve('inflight-reconnect-dedup', (False,True,3,5,9,False,2,'background')), True)
check('inflight-reconnect-dedup scenario 6', solve('inflight-reconnect-dedup', (True,True,3,12,9,False,0,'foreground')), False)
check('hidden-backlog-cap scenario 1', solve('hidden-backlog-cap', (True,True,N+2,5,5,False,3,'foreground')), 3)
check('hidden-backlog-cap scenario 2', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'foreground')), 1)
check('hidden-backlog-cap scenario 3', solve('hidden-backlog-cap', (True,False,3,5,9,False,1,'foreground')), 1)
check('hidden-backlog-cap scenario 4', solve('hidden-backlog-cap', (True,True,3,5,9,True,0,'foreground')), 0)
check('hidden-backlog-cap scenario 5', solve('hidden-backlog-cap', (False,True,3,5,9,False,2,'background')), 1)
check('hidden-backlog-cap scenario 6', solve('hidden-backlog-cap', (True,True,3,12,9,False,0,'foreground')), 0)
check('background-policy-override scenario 1', solve('background-policy-override', (True,True,N+2,5,5,False,3,'foreground')), True)
check('background-policy-override scenario 2', solve('background-policy-override', (False,True,3,5,9,False,2,'foreground')), False)
check('background-policy-override scenario 3', solve('background-policy-override', (True,False,3,5,9,False,1,'foreground')), True)
check('background-policy-override scenario 4', solve('background-policy-override', (True,True,3,5,9,True,0,'foreground')), True)
check('background-policy-override scenario 5', solve('background-policy-override', (False,True,3,5,9,False,2,'background')), True)
check('background-policy-override scenario 6', solve('background-policy-override', (True,True,3,12,9,False,0,'foreground')), True)
check('timer-install-when-online scenario 1', solve('timer-install-when-online', (True,True,N+2,5,5,False,3,'foreground')), N+2)
check('timer-install-when-online scenario 2', solve('timer-install-when-online', (False,True,3,5,9,False,2,'foreground')), None)
check('timer-install-when-online scenario 3', solve('timer-install-when-online', (True,False,3,5,9,False,1,'foreground')), None)
check('timer-install-when-online scenario 4', solve('timer-install-when-online', (True,True,3,5,9,True,0,'foreground')), 3)
check('timer-install-when-online scenario 5', solve('timer-install-when-online', (False,True,3,5,9,False,2,'background')), 3)
check('timer-install-when-online scenario 6', solve('timer-install-when-online', (True,True,3,12,9,False,0,'foreground')), 3)
check('poll-transition-state scenario 1', solve('poll-transition-state', (True,True,N+2,5,5,False,3,'foreground')), 'waiting')
check('poll-transition-state scenario 2', solve('poll-transition-state', (False,True,3,5,9,False,2,'foreground')), 'paused')
check('poll-transition-state scenario 3', solve('poll-transition-state', (True,False,3,5,9,False,1,'foreground')), 'paused')
check('poll-transition-state scenario 4', solve('poll-transition-state', (True,True,3,5,9,True,0,'foreground')), 'running')
check('poll-transition-state scenario 5', solve('poll-transition-state', (False,True,3,5,9,False,2,'background')), 'waiting')
check('poll-transition-state scenario 6', solve('poll-transition-state', (True,True,3,12,9,False,0,'foreground')), 'waiting')
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:
Offline poll reason.

Only one poll may be in flight. Foreground polling pauses offline or hidden; a background policy permits hidden work. Missed ticks coalesce into one catch-up request and scheduling restarts relative to the current clock. Operation offline-poll-reason has the six explicit input/output oracles below.

split: open-access