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

N = 1
observations = []
def solve(operation, s):
    cache, key, stale, observers, fetching, error = s
    if operation == 'cache-presence-not-truthiness':
        return key in cache
    if operation == 'stale-data-remains-visible':
        return cache.get(key)
    if operation == 'initial-vs-background-loading':
        return fetching and key not in cache
    if operation == 'observed-stale-refetch':
        return key in stale
    if operation == 'unobserved-garbage-collect':
        return not observers and not fetching
    if operation == 'resource-error-presence':
        return error is not None
    if operation == 'invalidate-one-resource':
        return list(dict.fromkeys(stale+[key]))
    if operation == 'evict-resource-key':
        return {k:v for k,v in cache.items() if k!=key}
    if operation == 'subscription-fanout-count':
        return len(observers)
    if operation == 'fetch-state-independent-of-data':
        return 'fetching' if fetching else 'idle'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cache-presence-not-truthiness scenario 1', solve('cache-presence-not-truthiness', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('cache-presence-not-truthiness scenario 2', solve('cache-presence-not-truthiness', ({'a':None},'a',[],[],False,'bad')), True)
check('cache-presence-not-truthiness scenario 3', solve('cache-presence-not-truthiness', ({},'a',[],['screen'],True,None)), False)
check('cache-presence-not-truthiness scenario 4', solve('cache-presence-not-truthiness', ({'a':0},'a',['a'],[],False,'')), True)
check('cache-presence-not-truthiness scenario 5', solve('cache-presence-not-truthiness', ({'b':N},'b',[],['one','two'],False,None)), True)
check('cache-presence-not-truthiness scenario 6', solve('cache-presence-not-truthiness', ({'a':[]},'a',['b'],[],True,None)), True)
check('stale-data-remains-visible scenario 1', solve('stale-data-remains-visible', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), N)
check('stale-data-remains-visible scenario 2', solve('stale-data-remains-visible', ({'a':None},'a',[],[],False,'bad')), None)
check('stale-data-remains-visible scenario 3', solve('stale-data-remains-visible', ({},'a',[],['screen'],True,None)), None)
check('stale-data-remains-visible scenario 4', solve('stale-data-remains-visible', ({'a':0},'a',['a'],[],False,'')), 0)
check('stale-data-remains-visible scenario 5', solve('stale-data-remains-visible', ({'b':N},'b',[],['one','two'],False,None)), N)
check('stale-data-remains-visible scenario 6', solve('stale-data-remains-visible', ({'a':[]},'a',['b'],[],True,None)), [])
check('initial-vs-background-loading scenario 1', solve('initial-vs-background-loading', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('initial-vs-background-loading scenario 2', solve('initial-vs-background-loading', ({'a':None},'a',[],[],False,'bad')), False)
check('initial-vs-background-loading scenario 3', solve('initial-vs-background-loading', ({},'a',[],['screen'],True,None)), True)
check('initial-vs-background-loading scenario 4', solve('initial-vs-background-loading', ({'a':0},'a',['a'],[],False,'')), False)
check('initial-vs-background-loading scenario 5', solve('initial-vs-background-loading', ({'b':N},'b',[],['one','two'],False,None)), False)
check('initial-vs-background-loading scenario 6', solve('initial-vs-background-loading', ({'a':[]},'a',['b'],[],True,None)), False)
check('observed-stale-refetch scenario 1', solve('observed-stale-refetch', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('observed-stale-refetch scenario 2', solve('observed-stale-refetch', ({'a':None},'a',[],[],False,'bad')), False)
check('observed-stale-refetch scenario 3', solve('observed-stale-refetch', ({},'a',[],['screen'],True,None)), False)
check('observed-stale-refetch scenario 4', solve('observed-stale-refetch', ({'a':0},'a',['a'],[],False,'')), False)
check('observed-stale-refetch scenario 5', solve('observed-stale-refetch', ({'b':N},'b',[],['one','two'],False,None)), False)
check('observed-stale-refetch scenario 6', solve('observed-stale-refetch', ({'a':[]},'a',['b'],[],True,None)), False)
check('unobserved-garbage-collect scenario 1', solve('unobserved-garbage-collect', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 2', solve('unobserved-garbage-collect', ({'a':None},'a',[],[],False,'bad')), True)
check('unobserved-garbage-collect scenario 3', solve('unobserved-garbage-collect', ({},'a',[],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 4', solve('unobserved-garbage-collect', ({'a':0},'a',['a'],[],False,'')), True)
check('unobserved-garbage-collect scenario 5', solve('unobserved-garbage-collect', ({'b':N},'b',[],['one','two'],False,None)), False)
check('unobserved-garbage-collect scenario 6', solve('unobserved-garbage-collect', ({'a':[]},'a',['b'],[],True,None)), False)
check('resource-error-presence scenario 1', solve('resource-error-presence', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('resource-error-presence scenario 2', solve('resource-error-presence', ({'a':None},'a',[],[],False,'bad')), True)
check('resource-error-presence scenario 3', solve('resource-error-presence', ({},'a',[],['screen'],True,None)), False)
check('resource-error-presence scenario 4', solve('resource-error-presence', ({'a':0},'a',['a'],[],False,'')), True)
check('resource-error-presence scenario 5', solve('resource-error-presence', ({'b':N},'b',[],['one','two'],False,None)), False)
check('resource-error-presence scenario 6', solve('resource-error-presence', ({'a':[]},'a',['b'],[],True,None)), False)
check('invalidate-one-resource scenario 1', solve('invalidate-one-resource', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 2', solve('invalidate-one-resource', ({'a':None},'a',[],[],False,'bad')), ['a'])
check('invalidate-one-resource scenario 3', solve('invalidate-one-resource', ({},'a',[],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 4', solve('invalidate-one-resource', ({'a':0},'a',['a'],[],False,'')), ['a'])
check('invalidate-one-resource scenario 5', solve('invalidate-one-resource', ({'b':N},'b',[],['one','two'],False,None)), ['b'])
check('invalidate-one-resource scenario 6', solve('invalidate-one-resource', ({'a':[]},'a',['b'],[],True,None)), ['b','a'])
check('evict-resource-key scenario 1', solve('evict-resource-key', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), {'b':0})
check('evict-resource-key scenario 2', solve('evict-resource-key', ({'a':None},'a',[],[],False,'bad')), {})
check('evict-resource-key scenario 3', solve('evict-resource-key', ({},'a',[],['screen'],True,None)), {})
check('evict-resource-key scenario 4', solve('evict-resource-key', ({'a':0},'a',['a'],[],False,'')), {})
check('evict-resource-key scenario 5', solve('evict-resource-key', ({'b':N},'b',[],['one','two'],False,None)), {})
check('evict-resource-key scenario 6', solve('evict-resource-key', ({'a':[]},'a',['b'],[],True,None)), {})
check('subscription-fanout-count scenario 1', solve('subscription-fanout-count', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 2', solve('subscription-fanout-count', ({'a':None},'a',[],[],False,'bad')), 0)
check('subscription-fanout-count scenario 3', solve('subscription-fanout-count', ({},'a',[],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 4', solve('subscription-fanout-count', ({'a':0},'a',['a'],[],False,'')), 0)
check('subscription-fanout-count scenario 5', solve('subscription-fanout-count', ({'b':N},'b',[],['one','two'],False,None)), 2)
check('subscription-fanout-count scenario 6', solve('subscription-fanout-count', ({'a':[]},'a',['b'],[],True,None)), 0)
check('fetch-state-independent-of-data scenario 1', solve('fetch-state-independent-of-data', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 2', solve('fetch-state-independent-of-data', ({'a':None},'a',[],[],False,'bad')), 'idle')
check('fetch-state-independent-of-data scenario 3', solve('fetch-state-independent-of-data', ({},'a',[],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 4', solve('fetch-state-independent-of-data', ({'a':0},'a',['a'],[],False,'')), 'idle')
check('fetch-state-independent-of-data scenario 5', solve('fetch-state-independent-of-data', ({'b':N},'b',[],['one','two'],False,None)), 'idle')
check('fetch-state-independent-of-data scenario 6', solve('fetch-state-independent-of-data', ({'a':[]},'a',['b'],[],True,None)), 'fetching')
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):
    cache, key, stale, observers, fetching, error = s
    if operation == 'cache-presence-not-truthiness':
        return key in cache
    if operation == 'stale-data-remains-visible':
        return cache.get(key)
    if operation == 'initial-vs-background-loading':
        return fetching and key not in cache
    if operation == 'observed-stale-refetch':
        return bool(observers)
    if operation == 'unobserved-garbage-collect':
        return not observers and not fetching
    if operation == 'resource-error-presence':
        return error is not None
    if operation == 'invalidate-one-resource':
        return list(dict.fromkeys(stale+[key]))
    if operation == 'evict-resource-key':
        return {k:v for k,v in cache.items() if k!=key}
    if operation == 'subscription-fanout-count':
        return len(observers)
    if operation == 'fetch-state-independent-of-data':
        return 'fetching' if fetching else 'idle'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cache-presence-not-truthiness scenario 1', solve('cache-presence-not-truthiness', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('cache-presence-not-truthiness scenario 2', solve('cache-presence-not-truthiness', ({'a':None},'a',[],[],False,'bad')), True)
check('cache-presence-not-truthiness scenario 3', solve('cache-presence-not-truthiness', ({},'a',[],['screen'],True,None)), False)
check('cache-presence-not-truthiness scenario 4', solve('cache-presence-not-truthiness', ({'a':0},'a',['a'],[],False,'')), True)
check('cache-presence-not-truthiness scenario 5', solve('cache-presence-not-truthiness', ({'b':N},'b',[],['one','two'],False,None)), True)
check('cache-presence-not-truthiness scenario 6', solve('cache-presence-not-truthiness', ({'a':[]},'a',['b'],[],True,None)), True)
check('stale-data-remains-visible scenario 1', solve('stale-data-remains-visible', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), N)
check('stale-data-remains-visible scenario 2', solve('stale-data-remains-visible', ({'a':None},'a',[],[],False,'bad')), None)
check('stale-data-remains-visible scenario 3', solve('stale-data-remains-visible', ({},'a',[],['screen'],True,None)), None)
check('stale-data-remains-visible scenario 4', solve('stale-data-remains-visible', ({'a':0},'a',['a'],[],False,'')), 0)
check('stale-data-remains-visible scenario 5', solve('stale-data-remains-visible', ({'b':N},'b',[],['one','two'],False,None)), N)
check('stale-data-remains-visible scenario 6', solve('stale-data-remains-visible', ({'a':[]},'a',['b'],[],True,None)), [])
check('initial-vs-background-loading scenario 1', solve('initial-vs-background-loading', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('initial-vs-background-loading scenario 2', solve('initial-vs-background-loading', ({'a':None},'a',[],[],False,'bad')), False)
check('initial-vs-background-loading scenario 3', solve('initial-vs-background-loading', ({},'a',[],['screen'],True,None)), True)
check('initial-vs-background-loading scenario 4', solve('initial-vs-background-loading', ({'a':0},'a',['a'],[],False,'')), False)
check('initial-vs-background-loading scenario 5', solve('initial-vs-background-loading', ({'b':N},'b',[],['one','two'],False,None)), False)
check('initial-vs-background-loading scenario 6', solve('initial-vs-background-loading', ({'a':[]},'a',['b'],[],True,None)), False)
check('observed-stale-refetch scenario 1', solve('observed-stale-refetch', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('observed-stale-refetch scenario 2', solve('observed-stale-refetch', ({'a':None},'a',[],[],False,'bad')), False)
check('observed-stale-refetch scenario 3', solve('observed-stale-refetch', ({},'a',[],['screen'],True,None)), False)
check('observed-stale-refetch scenario 4', solve('observed-stale-refetch', ({'a':0},'a',['a'],[],False,'')), False)
check('observed-stale-refetch scenario 5', solve('observed-stale-refetch', ({'b':N},'b',[],['one','two'],False,None)), False)
check('observed-stale-refetch scenario 6', solve('observed-stale-refetch', ({'a':[]},'a',['b'],[],True,None)), False)
check('unobserved-garbage-collect scenario 1', solve('unobserved-garbage-collect', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 2', solve('unobserved-garbage-collect', ({'a':None},'a',[],[],False,'bad')), True)
check('unobserved-garbage-collect scenario 3', solve('unobserved-garbage-collect', ({},'a',[],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 4', solve('unobserved-garbage-collect', ({'a':0},'a',['a'],[],False,'')), True)
check('unobserved-garbage-collect scenario 5', solve('unobserved-garbage-collect', ({'b':N},'b',[],['one','two'],False,None)), False)
check('unobserved-garbage-collect scenario 6', solve('unobserved-garbage-collect', ({'a':[]},'a',['b'],[],True,None)), False)
check('resource-error-presence scenario 1', solve('resource-error-presence', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('resource-error-presence scenario 2', solve('resource-error-presence', ({'a':None},'a',[],[],False,'bad')), True)
check('resource-error-presence scenario 3', solve('resource-error-presence', ({},'a',[],['screen'],True,None)), False)
check('resource-error-presence scenario 4', solve('resource-error-presence', ({'a':0},'a',['a'],[],False,'')), True)
check('resource-error-presence scenario 5', solve('resource-error-presence', ({'b':N},'b',[],['one','two'],False,None)), False)
check('resource-error-presence scenario 6', solve('resource-error-presence', ({'a':[]},'a',['b'],[],True,None)), False)
check('invalidate-one-resource scenario 1', solve('invalidate-one-resource', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 2', solve('invalidate-one-resource', ({'a':None},'a',[],[],False,'bad')), ['a'])
check('invalidate-one-resource scenario 3', solve('invalidate-one-resource', ({},'a',[],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 4', solve('invalidate-one-resource', ({'a':0},'a',['a'],[],False,'')), ['a'])
check('invalidate-one-resource scenario 5', solve('invalidate-one-resource', ({'b':N},'b',[],['one','two'],False,None)), ['b'])
check('invalidate-one-resource scenario 6', solve('invalidate-one-resource', ({'a':[]},'a',['b'],[],True,None)), ['b','a'])
check('evict-resource-key scenario 1', solve('evict-resource-key', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), {'b':0})
check('evict-resource-key scenario 2', solve('evict-resource-key', ({'a':None},'a',[],[],False,'bad')), {})
check('evict-resource-key scenario 3', solve('evict-resource-key', ({},'a',[],['screen'],True,None)), {})
check('evict-resource-key scenario 4', solve('evict-resource-key', ({'a':0},'a',['a'],[],False,'')), {})
check('evict-resource-key scenario 5', solve('evict-resource-key', ({'b':N},'b',[],['one','two'],False,None)), {})
check('evict-resource-key scenario 6', solve('evict-resource-key', ({'a':[]},'a',['b'],[],True,None)), {})
check('subscription-fanout-count scenario 1', solve('subscription-fanout-count', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 2', solve('subscription-fanout-count', ({'a':None},'a',[],[],False,'bad')), 0)
check('subscription-fanout-count scenario 3', solve('subscription-fanout-count', ({},'a',[],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 4', solve('subscription-fanout-count', ({'a':0},'a',['a'],[],False,'')), 0)
check('subscription-fanout-count scenario 5', solve('subscription-fanout-count', ({'b':N},'b',[],['one','two'],False,None)), 2)
check('subscription-fanout-count scenario 6', solve('subscription-fanout-count', ({'a':[]},'a',['b'],[],True,None)), 0)
check('fetch-state-independent-of-data scenario 1', solve('fetch-state-independent-of-data', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 2', solve('fetch-state-independent-of-data', ({'a':None},'a',[],[],False,'bad')), 'idle')
check('fetch-state-independent-of-data scenario 3', solve('fetch-state-independent-of-data', ({},'a',[],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 4', solve('fetch-state-independent-of-data', ({'a':0},'a',['a'],[],False,'')), 'idle')
check('fetch-state-independent-of-data scenario 5', solve('fetch-state-independent-of-data', ({'b':N},'b',[],['one','two'],False,None)), 'idle')
check('fetch-state-independent-of-data scenario 6', solve('fetch-state-independent-of-data', ({'a':[]},'a',['b'],[],True,None)), 'fetching')
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:
Observed stale refetch.

Client cache presence is independent of payload truthiness. Stale data remains visible during background refresh; first-load status requires absent data. Observers retain resources, and invalidation is idempotent per key. Operation observed-stale-refetch 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):
    cache, key, stale, observers, fetching, error = s
    if operation == 'cache-presence-not-truthiness':
        return key in cache
    if operation == 'stale-data-remains-visible':
        return cache.get(key)
    if operation == 'initial-vs-background-loading':
        return fetching and key not in cache
    if operation == 'observed-stale-refetch':
        return key in stale and bool(observers)
    if operation == 'unobserved-garbage-collect':
        return not observers
    if operation == 'resource-error-presence':
        return error is not None
    if operation == 'invalidate-one-resource':
        return list(dict.fromkeys(stale+[key]))
    if operation == 'evict-resource-key':
        return {k:v for k,v in cache.items() if k!=key}
    if operation == 'subscription-fanout-count':
        return len(observers)
    if operation == 'fetch-state-independent-of-data':
        return 'fetching' if fetching else 'idle'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cache-presence-not-truthiness scenario 1', solve('cache-presence-not-truthiness', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('cache-presence-not-truthiness scenario 2', solve('cache-presence-not-truthiness', ({'a':None},'a',[],[],False,'bad')), True)
check('cache-presence-not-truthiness scenario 3', solve('cache-presence-not-truthiness', ({},'a',[],['screen'],True,None)), False)
check('cache-presence-not-truthiness scenario 4', solve('cache-presence-not-truthiness', ({'a':0},'a',['a'],[],False,'')), True)
check('cache-presence-not-truthiness scenario 5', solve('cache-presence-not-truthiness', ({'b':N},'b',[],['one','two'],False,None)), True)
check('cache-presence-not-truthiness scenario 6', solve('cache-presence-not-truthiness', ({'a':[]},'a',['b'],[],True,None)), True)
check('stale-data-remains-visible scenario 1', solve('stale-data-remains-visible', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), N)
check('stale-data-remains-visible scenario 2', solve('stale-data-remains-visible', ({'a':None},'a',[],[],False,'bad')), None)
check('stale-data-remains-visible scenario 3', solve('stale-data-remains-visible', ({},'a',[],['screen'],True,None)), None)
check('stale-data-remains-visible scenario 4', solve('stale-data-remains-visible', ({'a':0},'a',['a'],[],False,'')), 0)
check('stale-data-remains-visible scenario 5', solve('stale-data-remains-visible', ({'b':N},'b',[],['one','two'],False,None)), N)
check('stale-data-remains-visible scenario 6', solve('stale-data-remains-visible', ({'a':[]},'a',['b'],[],True,None)), [])
check('initial-vs-background-loading scenario 1', solve('initial-vs-background-loading', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('initial-vs-background-loading scenario 2', solve('initial-vs-background-loading', ({'a':None},'a',[],[],False,'bad')), False)
check('initial-vs-background-loading scenario 3', solve('initial-vs-background-loading', ({},'a',[],['screen'],True,None)), True)
check('initial-vs-background-loading scenario 4', solve('initial-vs-background-loading', ({'a':0},'a',['a'],[],False,'')), False)
check('initial-vs-background-loading scenario 5', solve('initial-vs-background-loading', ({'b':N},'b',[],['one','two'],False,None)), False)
check('initial-vs-background-loading scenario 6', solve('initial-vs-background-loading', ({'a':[]},'a',['b'],[],True,None)), False)
check('observed-stale-refetch scenario 1', solve('observed-stale-refetch', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('observed-stale-refetch scenario 2', solve('observed-stale-refetch', ({'a':None},'a',[],[],False,'bad')), False)
check('observed-stale-refetch scenario 3', solve('observed-stale-refetch', ({},'a',[],['screen'],True,None)), False)
check('observed-stale-refetch scenario 4', solve('observed-stale-refetch', ({'a':0},'a',['a'],[],False,'')), False)
check('observed-stale-refetch scenario 5', solve('observed-stale-refetch', ({'b':N},'b',[],['one','two'],False,None)), False)
check('observed-stale-refetch scenario 6', solve('observed-stale-refetch', ({'a':[]},'a',['b'],[],True,None)), False)
check('unobserved-garbage-collect scenario 1', solve('unobserved-garbage-collect', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 2', solve('unobserved-garbage-collect', ({'a':None},'a',[],[],False,'bad')), True)
check('unobserved-garbage-collect scenario 3', solve('unobserved-garbage-collect', ({},'a',[],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 4', solve('unobserved-garbage-collect', ({'a':0},'a',['a'],[],False,'')), True)
check('unobserved-garbage-collect scenario 5', solve('unobserved-garbage-collect', ({'b':N},'b',[],['one','two'],False,None)), False)
check('unobserved-garbage-collect scenario 6', solve('unobserved-garbage-collect', ({'a':[]},'a',['b'],[],True,None)), False)
check('resource-error-presence scenario 1', solve('resource-error-presence', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('resource-error-presence scenario 2', solve('resource-error-presence', ({'a':None},'a',[],[],False,'bad')), True)
check('resource-error-presence scenario 3', solve('resource-error-presence', ({},'a',[],['screen'],True,None)), False)
check('resource-error-presence scenario 4', solve('resource-error-presence', ({'a':0},'a',['a'],[],False,'')), True)
check('resource-error-presence scenario 5', solve('resource-error-presence', ({'b':N},'b',[],['one','two'],False,None)), False)
check('resource-error-presence scenario 6', solve('resource-error-presence', ({'a':[]},'a',['b'],[],True,None)), False)
check('invalidate-one-resource scenario 1', solve('invalidate-one-resource', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 2', solve('invalidate-one-resource', ({'a':None},'a',[],[],False,'bad')), ['a'])
check('invalidate-one-resource scenario 3', solve('invalidate-one-resource', ({},'a',[],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 4', solve('invalidate-one-resource', ({'a':0},'a',['a'],[],False,'')), ['a'])
check('invalidate-one-resource scenario 5', solve('invalidate-one-resource', ({'b':N},'b',[],['one','two'],False,None)), ['b'])
check('invalidate-one-resource scenario 6', solve('invalidate-one-resource', ({'a':[]},'a',['b'],[],True,None)), ['b','a'])
check('evict-resource-key scenario 1', solve('evict-resource-key', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), {'b':0})
check('evict-resource-key scenario 2', solve('evict-resource-key', ({'a':None},'a',[],[],False,'bad')), {})
check('evict-resource-key scenario 3', solve('evict-resource-key', ({},'a',[],['screen'],True,None)), {})
check('evict-resource-key scenario 4', solve('evict-resource-key', ({'a':0},'a',['a'],[],False,'')), {})
check('evict-resource-key scenario 5', solve('evict-resource-key', ({'b':N},'b',[],['one','two'],False,None)), {})
check('evict-resource-key scenario 6', solve('evict-resource-key', ({'a':[]},'a',['b'],[],True,None)), {})
check('subscription-fanout-count scenario 1', solve('subscription-fanout-count', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 2', solve('subscription-fanout-count', ({'a':None},'a',[],[],False,'bad')), 0)
check('subscription-fanout-count scenario 3', solve('subscription-fanout-count', ({},'a',[],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 4', solve('subscription-fanout-count', ({'a':0},'a',['a'],[],False,'')), 0)
check('subscription-fanout-count scenario 5', solve('subscription-fanout-count', ({'b':N},'b',[],['one','two'],False,None)), 2)
check('subscription-fanout-count scenario 6', solve('subscription-fanout-count', ({'a':[]},'a',['b'],[],True,None)), 0)
check('fetch-state-independent-of-data scenario 1', solve('fetch-state-independent-of-data', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 2', solve('fetch-state-independent-of-data', ({'a':None},'a',[],[],False,'bad')), 'idle')
check('fetch-state-independent-of-data scenario 3', solve('fetch-state-independent-of-data', ({},'a',[],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 4', solve('fetch-state-independent-of-data', ({'a':0},'a',['a'],[],False,'')), 'idle')
check('fetch-state-independent-of-data scenario 5', solve('fetch-state-independent-of-data', ({'b':N},'b',[],['one','two'],False,None)), 'idle')
check('fetch-state-independent-of-data scenario 6', solve('fetch-state-independent-of-data', ({'a':[]},'a',['b'],[],True,None)), 'fetching')
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):
    cache, key, stale, observers, fetching, error = s
    if operation == 'cache-presence-not-truthiness':
        return key in cache
    if operation == 'stale-data-remains-visible':
        return cache.get(key)
    if operation == 'initial-vs-background-loading':
        return fetching and key not in cache
    if operation == 'observed-stale-refetch':
        return key in stale and bool(observers)
    if operation == 'unobserved-garbage-collect':
        return not fetching
    if operation == 'resource-error-presence':
        return error is not None
    if operation == 'invalidate-one-resource':
        return list(dict.fromkeys(stale+[key]))
    if operation == 'evict-resource-key':
        return {k:v for k,v in cache.items() if k!=key}
    if operation == 'subscription-fanout-count':
        return len(observers)
    if operation == 'fetch-state-independent-of-data':
        return 'fetching' if fetching else 'idle'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cache-presence-not-truthiness scenario 1', solve('cache-presence-not-truthiness', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('cache-presence-not-truthiness scenario 2', solve('cache-presence-not-truthiness', ({'a':None},'a',[],[],False,'bad')), True)
check('cache-presence-not-truthiness scenario 3', solve('cache-presence-not-truthiness', ({},'a',[],['screen'],True,None)), False)
check('cache-presence-not-truthiness scenario 4', solve('cache-presence-not-truthiness', ({'a':0},'a',['a'],[],False,'')), True)
check('cache-presence-not-truthiness scenario 5', solve('cache-presence-not-truthiness', ({'b':N},'b',[],['one','two'],False,None)), True)
check('cache-presence-not-truthiness scenario 6', solve('cache-presence-not-truthiness', ({'a':[]},'a',['b'],[],True,None)), True)
check('stale-data-remains-visible scenario 1', solve('stale-data-remains-visible', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), N)
check('stale-data-remains-visible scenario 2', solve('stale-data-remains-visible', ({'a':None},'a',[],[],False,'bad')), None)
check('stale-data-remains-visible scenario 3', solve('stale-data-remains-visible', ({},'a',[],['screen'],True,None)), None)
check('stale-data-remains-visible scenario 4', solve('stale-data-remains-visible', ({'a':0},'a',['a'],[],False,'')), 0)
check('stale-data-remains-visible scenario 5', solve('stale-data-remains-visible', ({'b':N},'b',[],['one','two'],False,None)), N)
check('stale-data-remains-visible scenario 6', solve('stale-data-remains-visible', ({'a':[]},'a',['b'],[],True,None)), [])
check('initial-vs-background-loading scenario 1', solve('initial-vs-background-loading', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('initial-vs-background-loading scenario 2', solve('initial-vs-background-loading', ({'a':None},'a',[],[],False,'bad')), False)
check('initial-vs-background-loading scenario 3', solve('initial-vs-background-loading', ({},'a',[],['screen'],True,None)), True)
check('initial-vs-background-loading scenario 4', solve('initial-vs-background-loading', ({'a':0},'a',['a'],[],False,'')), False)
check('initial-vs-background-loading scenario 5', solve('initial-vs-background-loading', ({'b':N},'b',[],['one','two'],False,None)), False)
check('initial-vs-background-loading scenario 6', solve('initial-vs-background-loading', ({'a':[]},'a',['b'],[],True,None)), False)
check('observed-stale-refetch scenario 1', solve('observed-stale-refetch', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('observed-stale-refetch scenario 2', solve('observed-stale-refetch', ({'a':None},'a',[],[],False,'bad')), False)
check('observed-stale-refetch scenario 3', solve('observed-stale-refetch', ({},'a',[],['screen'],True,None)), False)
check('observed-stale-refetch scenario 4', solve('observed-stale-refetch', ({'a':0},'a',['a'],[],False,'')), False)
check('observed-stale-refetch scenario 5', solve('observed-stale-refetch', ({'b':N},'b',[],['one','two'],False,None)), False)
check('observed-stale-refetch scenario 6', solve('observed-stale-refetch', ({'a':[]},'a',['b'],[],True,None)), False)
check('unobserved-garbage-collect scenario 1', solve('unobserved-garbage-collect', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 2', solve('unobserved-garbage-collect', ({'a':None},'a',[],[],False,'bad')), True)
check('unobserved-garbage-collect scenario 3', solve('unobserved-garbage-collect', ({},'a',[],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 4', solve('unobserved-garbage-collect', ({'a':0},'a',['a'],[],False,'')), True)
check('unobserved-garbage-collect scenario 5', solve('unobserved-garbage-collect', ({'b':N},'b',[],['one','two'],False,None)), False)
check('unobserved-garbage-collect scenario 6', solve('unobserved-garbage-collect', ({'a':[]},'a',['b'],[],True,None)), False)
check('resource-error-presence scenario 1', solve('resource-error-presence', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('resource-error-presence scenario 2', solve('resource-error-presence', ({'a':None},'a',[],[],False,'bad')), True)
check('resource-error-presence scenario 3', solve('resource-error-presence', ({},'a',[],['screen'],True,None)), False)
check('resource-error-presence scenario 4', solve('resource-error-presence', ({'a':0},'a',['a'],[],False,'')), True)
check('resource-error-presence scenario 5', solve('resource-error-presence', ({'b':N},'b',[],['one','two'],False,None)), False)
check('resource-error-presence scenario 6', solve('resource-error-presence', ({'a':[]},'a',['b'],[],True,None)), False)
check('invalidate-one-resource scenario 1', solve('invalidate-one-resource', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 2', solve('invalidate-one-resource', ({'a':None},'a',[],[],False,'bad')), ['a'])
check('invalidate-one-resource scenario 3', solve('invalidate-one-resource', ({},'a',[],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 4', solve('invalidate-one-resource', ({'a':0},'a',['a'],[],False,'')), ['a'])
check('invalidate-one-resource scenario 5', solve('invalidate-one-resource', ({'b':N},'b',[],['one','two'],False,None)), ['b'])
check('invalidate-one-resource scenario 6', solve('invalidate-one-resource', ({'a':[]},'a',['b'],[],True,None)), ['b','a'])
check('evict-resource-key scenario 1', solve('evict-resource-key', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), {'b':0})
check('evict-resource-key scenario 2', solve('evict-resource-key', ({'a':None},'a',[],[],False,'bad')), {})
check('evict-resource-key scenario 3', solve('evict-resource-key', ({},'a',[],['screen'],True,None)), {})
check('evict-resource-key scenario 4', solve('evict-resource-key', ({'a':0},'a',['a'],[],False,'')), {})
check('evict-resource-key scenario 5', solve('evict-resource-key', ({'b':N},'b',[],['one','two'],False,None)), {})
check('evict-resource-key scenario 6', solve('evict-resource-key', ({'a':[]},'a',['b'],[],True,None)), {})
check('subscription-fanout-count scenario 1', solve('subscription-fanout-count', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 2', solve('subscription-fanout-count', ({'a':None},'a',[],[],False,'bad')), 0)
check('subscription-fanout-count scenario 3', solve('subscription-fanout-count', ({},'a',[],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 4', solve('subscription-fanout-count', ({'a':0},'a',['a'],[],False,'')), 0)
check('subscription-fanout-count scenario 5', solve('subscription-fanout-count', ({'b':N},'b',[],['one','two'],False,None)), 2)
check('subscription-fanout-count scenario 6', solve('subscription-fanout-count', ({'a':[]},'a',['b'],[],True,None)), 0)
check('fetch-state-independent-of-data scenario 1', solve('fetch-state-independent-of-data', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 2', solve('fetch-state-independent-of-data', ({'a':None},'a',[],[],False,'bad')), 'idle')
check('fetch-state-independent-of-data scenario 3', solve('fetch-state-independent-of-data', ({},'a',[],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 4', solve('fetch-state-independent-of-data', ({'a':0},'a',['a'],[],False,'')), 'idle')
check('fetch-state-independent-of-data scenario 5', solve('fetch-state-independent-of-data', ({'b':N},'b',[],['one','two'],False,None)), 'idle')
check('fetch-state-independent-of-data scenario 6', solve('fetch-state-independent-of-data', ({'a':[]},'a',['b'],[],True,None)), 'fetching')
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:
Unobserved garbage collect.

Client cache presence is independent of payload truthiness. Stale data remains visible during background refresh; first-load status requires absent data. Observers retain resources, and invalidation is idempotent per key. Operation unobserved-garbage-collect 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):
    cache, key, stale, observers, fetching, error = s
    if operation == 'cache-presence-not-truthiness':
        return key in cache
    if operation == 'stale-data-remains-visible':
        return cache.get(key)
    if operation == 'initial-vs-background-loading':
        return fetching and key not in cache
    if operation == 'observed-stale-refetch':
        return key in stale and bool(observers)
    if operation == 'unobserved-garbage-collect':
        return not observers and not fetching
    if operation == 'resource-error-presence':
        return error is not None
    if operation == 'invalidate-one-resource':
        return [key]
    if operation == 'evict-resource-key':
        return {k:v for k,v in cache.items() if k!=key}
    if operation == 'subscription-fanout-count':
        return len(observers)
    if operation == 'fetch-state-independent-of-data':
        return 'fetching' if fetching else 'idle'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cache-presence-not-truthiness scenario 1', solve('cache-presence-not-truthiness', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('cache-presence-not-truthiness scenario 2', solve('cache-presence-not-truthiness', ({'a':None},'a',[],[],False,'bad')), True)
check('cache-presence-not-truthiness scenario 3', solve('cache-presence-not-truthiness', ({},'a',[],['screen'],True,None)), False)
check('cache-presence-not-truthiness scenario 4', solve('cache-presence-not-truthiness', ({'a':0},'a',['a'],[],False,'')), True)
check('cache-presence-not-truthiness scenario 5', solve('cache-presence-not-truthiness', ({'b':N},'b',[],['one','two'],False,None)), True)
check('cache-presence-not-truthiness scenario 6', solve('cache-presence-not-truthiness', ({'a':[]},'a',['b'],[],True,None)), True)
check('stale-data-remains-visible scenario 1', solve('stale-data-remains-visible', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), N)
check('stale-data-remains-visible scenario 2', solve('stale-data-remains-visible', ({'a':None},'a',[],[],False,'bad')), None)
check('stale-data-remains-visible scenario 3', solve('stale-data-remains-visible', ({},'a',[],['screen'],True,None)), None)
check('stale-data-remains-visible scenario 4', solve('stale-data-remains-visible', ({'a':0},'a',['a'],[],False,'')), 0)
check('stale-data-remains-visible scenario 5', solve('stale-data-remains-visible', ({'b':N},'b',[],['one','two'],False,None)), N)
check('stale-data-remains-visible scenario 6', solve('stale-data-remains-visible', ({'a':[]},'a',['b'],[],True,None)), [])
check('initial-vs-background-loading scenario 1', solve('initial-vs-background-loading', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('initial-vs-background-loading scenario 2', solve('initial-vs-background-loading', ({'a':None},'a',[],[],False,'bad')), False)
check('initial-vs-background-loading scenario 3', solve('initial-vs-background-loading', ({},'a',[],['screen'],True,None)), True)
check('initial-vs-background-loading scenario 4', solve('initial-vs-background-loading', ({'a':0},'a',['a'],[],False,'')), False)
check('initial-vs-background-loading scenario 5', solve('initial-vs-background-loading', ({'b':N},'b',[],['one','two'],False,None)), False)
check('initial-vs-background-loading scenario 6', solve('initial-vs-background-loading', ({'a':[]},'a',['b'],[],True,None)), False)
check('observed-stale-refetch scenario 1', solve('observed-stale-refetch', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('observed-stale-refetch scenario 2', solve('observed-stale-refetch', ({'a':None},'a',[],[],False,'bad')), False)
check('observed-stale-refetch scenario 3', solve('observed-stale-refetch', ({},'a',[],['screen'],True,None)), False)
check('observed-stale-refetch scenario 4', solve('observed-stale-refetch', ({'a':0},'a',['a'],[],False,'')), False)
check('observed-stale-refetch scenario 5', solve('observed-stale-refetch', ({'b':N},'b',[],['one','two'],False,None)), False)
check('observed-stale-refetch scenario 6', solve('observed-stale-refetch', ({'a':[]},'a',['b'],[],True,None)), False)
check('unobserved-garbage-collect scenario 1', solve('unobserved-garbage-collect', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 2', solve('unobserved-garbage-collect', ({'a':None},'a',[],[],False,'bad')), True)
check('unobserved-garbage-collect scenario 3', solve('unobserved-garbage-collect', ({},'a',[],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 4', solve('unobserved-garbage-collect', ({'a':0},'a',['a'],[],False,'')), True)
check('unobserved-garbage-collect scenario 5', solve('unobserved-garbage-collect', ({'b':N},'b',[],['one','two'],False,None)), False)
check('unobserved-garbage-collect scenario 6', solve('unobserved-garbage-collect', ({'a':[]},'a',['b'],[],True,None)), False)
check('resource-error-presence scenario 1', solve('resource-error-presence', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('resource-error-presence scenario 2', solve('resource-error-presence', ({'a':None},'a',[],[],False,'bad')), True)
check('resource-error-presence scenario 3', solve('resource-error-presence', ({},'a',[],['screen'],True,None)), False)
check('resource-error-presence scenario 4', solve('resource-error-presence', ({'a':0},'a',['a'],[],False,'')), True)
check('resource-error-presence scenario 5', solve('resource-error-presence', ({'b':N},'b',[],['one','two'],False,None)), False)
check('resource-error-presence scenario 6', solve('resource-error-presence', ({'a':[]},'a',['b'],[],True,None)), False)
check('invalidate-one-resource scenario 1', solve('invalidate-one-resource', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 2', solve('invalidate-one-resource', ({'a':None},'a',[],[],False,'bad')), ['a'])
check('invalidate-one-resource scenario 3', solve('invalidate-one-resource', ({},'a',[],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 4', solve('invalidate-one-resource', ({'a':0},'a',['a'],[],False,'')), ['a'])
check('invalidate-one-resource scenario 5', solve('invalidate-one-resource', ({'b':N},'b',[],['one','two'],False,None)), ['b'])
check('invalidate-one-resource scenario 6', solve('invalidate-one-resource', ({'a':[]},'a',['b'],[],True,None)), ['b','a'])
check('evict-resource-key scenario 1', solve('evict-resource-key', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), {'b':0})
check('evict-resource-key scenario 2', solve('evict-resource-key', ({'a':None},'a',[],[],False,'bad')), {})
check('evict-resource-key scenario 3', solve('evict-resource-key', ({},'a',[],['screen'],True,None)), {})
check('evict-resource-key scenario 4', solve('evict-resource-key', ({'a':0},'a',['a'],[],False,'')), {})
check('evict-resource-key scenario 5', solve('evict-resource-key', ({'b':N},'b',[],['one','two'],False,None)), {})
check('evict-resource-key scenario 6', solve('evict-resource-key', ({'a':[]},'a',['b'],[],True,None)), {})
check('subscription-fanout-count scenario 1', solve('subscription-fanout-count', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 2', solve('subscription-fanout-count', ({'a':None},'a',[],[],False,'bad')), 0)
check('subscription-fanout-count scenario 3', solve('subscription-fanout-count', ({},'a',[],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 4', solve('subscription-fanout-count', ({'a':0},'a',['a'],[],False,'')), 0)
check('subscription-fanout-count scenario 5', solve('subscription-fanout-count', ({'b':N},'b',[],['one','two'],False,None)), 2)
check('subscription-fanout-count scenario 6', solve('subscription-fanout-count', ({'a':[]},'a',['b'],[],True,None)), 0)
check('fetch-state-independent-of-data scenario 1', solve('fetch-state-independent-of-data', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 2', solve('fetch-state-independent-of-data', ({'a':None},'a',[],[],False,'bad')), 'idle')
check('fetch-state-independent-of-data scenario 3', solve('fetch-state-independent-of-data', ({},'a',[],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 4', solve('fetch-state-independent-of-data', ({'a':0},'a',['a'],[],False,'')), 'idle')
check('fetch-state-independent-of-data scenario 5', solve('fetch-state-independent-of-data', ({'b':N},'b',[],['one','two'],False,None)), 'idle')
check('fetch-state-independent-of-data scenario 6', solve('fetch-state-independent-of-data', ({'a':[]},'a',['b'],[],True,None)), 'fetching')
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):
    cache, key, stale, observers, fetching, error = s
    if operation == 'cache-presence-not-truthiness':
        return key in cache
    if operation == 'stale-data-remains-visible':
        return cache.get(key)
    if operation == 'initial-vs-background-loading':
        return fetching and key not in cache
    if operation == 'observed-stale-refetch':
        return key in stale and bool(observers)
    if operation == 'unobserved-garbage-collect':
        return not observers and not fetching
    if operation == 'resource-error-presence':
        return error is not None
    if operation == 'invalidate-one-resource':
        return stale+[key]
    if operation == 'evict-resource-key':
        return {k:v for k,v in cache.items() if k!=key}
    if operation == 'subscription-fanout-count':
        return len(observers)
    if operation == 'fetch-state-independent-of-data':
        return 'fetching' if fetching else 'idle'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cache-presence-not-truthiness scenario 1', solve('cache-presence-not-truthiness', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('cache-presence-not-truthiness scenario 2', solve('cache-presence-not-truthiness', ({'a':None},'a',[],[],False,'bad')), True)
check('cache-presence-not-truthiness scenario 3', solve('cache-presence-not-truthiness', ({},'a',[],['screen'],True,None)), False)
check('cache-presence-not-truthiness scenario 4', solve('cache-presence-not-truthiness', ({'a':0},'a',['a'],[],False,'')), True)
check('cache-presence-not-truthiness scenario 5', solve('cache-presence-not-truthiness', ({'b':N},'b',[],['one','two'],False,None)), True)
check('cache-presence-not-truthiness scenario 6', solve('cache-presence-not-truthiness', ({'a':[]},'a',['b'],[],True,None)), True)
check('stale-data-remains-visible scenario 1', solve('stale-data-remains-visible', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), N)
check('stale-data-remains-visible scenario 2', solve('stale-data-remains-visible', ({'a':None},'a',[],[],False,'bad')), None)
check('stale-data-remains-visible scenario 3', solve('stale-data-remains-visible', ({},'a',[],['screen'],True,None)), None)
check('stale-data-remains-visible scenario 4', solve('stale-data-remains-visible', ({'a':0},'a',['a'],[],False,'')), 0)
check('stale-data-remains-visible scenario 5', solve('stale-data-remains-visible', ({'b':N},'b',[],['one','two'],False,None)), N)
check('stale-data-remains-visible scenario 6', solve('stale-data-remains-visible', ({'a':[]},'a',['b'],[],True,None)), [])
check('initial-vs-background-loading scenario 1', solve('initial-vs-background-loading', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('initial-vs-background-loading scenario 2', solve('initial-vs-background-loading', ({'a':None},'a',[],[],False,'bad')), False)
check('initial-vs-background-loading scenario 3', solve('initial-vs-background-loading', ({},'a',[],['screen'],True,None)), True)
check('initial-vs-background-loading scenario 4', solve('initial-vs-background-loading', ({'a':0},'a',['a'],[],False,'')), False)
check('initial-vs-background-loading scenario 5', solve('initial-vs-background-loading', ({'b':N},'b',[],['one','two'],False,None)), False)
check('initial-vs-background-loading scenario 6', solve('initial-vs-background-loading', ({'a':[]},'a',['b'],[],True,None)), False)
check('observed-stale-refetch scenario 1', solve('observed-stale-refetch', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('observed-stale-refetch scenario 2', solve('observed-stale-refetch', ({'a':None},'a',[],[],False,'bad')), False)
check('observed-stale-refetch scenario 3', solve('observed-stale-refetch', ({},'a',[],['screen'],True,None)), False)
check('observed-stale-refetch scenario 4', solve('observed-stale-refetch', ({'a':0},'a',['a'],[],False,'')), False)
check('observed-stale-refetch scenario 5', solve('observed-stale-refetch', ({'b':N},'b',[],['one','two'],False,None)), False)
check('observed-stale-refetch scenario 6', solve('observed-stale-refetch', ({'a':[]},'a',['b'],[],True,None)), False)
check('unobserved-garbage-collect scenario 1', solve('unobserved-garbage-collect', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 2', solve('unobserved-garbage-collect', ({'a':None},'a',[],[],False,'bad')), True)
check('unobserved-garbage-collect scenario 3', solve('unobserved-garbage-collect', ({},'a',[],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 4', solve('unobserved-garbage-collect', ({'a':0},'a',['a'],[],False,'')), True)
check('unobserved-garbage-collect scenario 5', solve('unobserved-garbage-collect', ({'b':N},'b',[],['one','two'],False,None)), False)
check('unobserved-garbage-collect scenario 6', solve('unobserved-garbage-collect', ({'a':[]},'a',['b'],[],True,None)), False)
check('resource-error-presence scenario 1', solve('resource-error-presence', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('resource-error-presence scenario 2', solve('resource-error-presence', ({'a':None},'a',[],[],False,'bad')), True)
check('resource-error-presence scenario 3', solve('resource-error-presence', ({},'a',[],['screen'],True,None)), False)
check('resource-error-presence scenario 4', solve('resource-error-presence', ({'a':0},'a',['a'],[],False,'')), True)
check('resource-error-presence scenario 5', solve('resource-error-presence', ({'b':N},'b',[],['one','two'],False,None)), False)
check('resource-error-presence scenario 6', solve('resource-error-presence', ({'a':[]},'a',['b'],[],True,None)), False)
check('invalidate-one-resource scenario 1', solve('invalidate-one-resource', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 2', solve('invalidate-one-resource', ({'a':None},'a',[],[],False,'bad')), ['a'])
check('invalidate-one-resource scenario 3', solve('invalidate-one-resource', ({},'a',[],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 4', solve('invalidate-one-resource', ({'a':0},'a',['a'],[],False,'')), ['a'])
check('invalidate-one-resource scenario 5', solve('invalidate-one-resource', ({'b':N},'b',[],['one','two'],False,None)), ['b'])
check('invalidate-one-resource scenario 6', solve('invalidate-one-resource', ({'a':[]},'a',['b'],[],True,None)), ['b','a'])
check('evict-resource-key scenario 1', solve('evict-resource-key', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), {'b':0})
check('evict-resource-key scenario 2', solve('evict-resource-key', ({'a':None},'a',[],[],False,'bad')), {})
check('evict-resource-key scenario 3', solve('evict-resource-key', ({},'a',[],['screen'],True,None)), {})
check('evict-resource-key scenario 4', solve('evict-resource-key', ({'a':0},'a',['a'],[],False,'')), {})
check('evict-resource-key scenario 5', solve('evict-resource-key', ({'b':N},'b',[],['one','two'],False,None)), {})
check('evict-resource-key scenario 6', solve('evict-resource-key', ({'a':[]},'a',['b'],[],True,None)), {})
check('subscription-fanout-count scenario 1', solve('subscription-fanout-count', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 2', solve('subscription-fanout-count', ({'a':None},'a',[],[],False,'bad')), 0)
check('subscription-fanout-count scenario 3', solve('subscription-fanout-count', ({},'a',[],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 4', solve('subscription-fanout-count', ({'a':0},'a',['a'],[],False,'')), 0)
check('subscription-fanout-count scenario 5', solve('subscription-fanout-count', ({'b':N},'b',[],['one','two'],False,None)), 2)
check('subscription-fanout-count scenario 6', solve('subscription-fanout-count', ({'a':[]},'a',['b'],[],True,None)), 0)
check('fetch-state-independent-of-data scenario 1', solve('fetch-state-independent-of-data', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 2', solve('fetch-state-independent-of-data', ({'a':None},'a',[],[],False,'bad')), 'idle')
check('fetch-state-independent-of-data scenario 3', solve('fetch-state-independent-of-data', ({},'a',[],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 4', solve('fetch-state-independent-of-data', ({'a':0},'a',['a'],[],False,'')), 'idle')
check('fetch-state-independent-of-data scenario 5', solve('fetch-state-independent-of-data', ({'b':N},'b',[],['one','two'],False,None)), 'idle')
check('fetch-state-independent-of-data scenario 6', solve('fetch-state-independent-of-data', ({'a':[]},'a',['b'],[],True,None)), 'fetching')
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:
Invalidate one resource.

Client cache presence is independent of payload truthiness. Stale data remains visible during background refresh; first-load status requires absent data. Observers retain resources, and invalidation is idempotent per key. Operation invalidate-one-resource 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):
    cache, key, stale, observers, fetching, error = s
    if operation == 'cache-presence-not-truthiness':
        return key in cache
    if operation == 'stale-data-remains-visible':
        return cache.get(key)
    if operation == 'initial-vs-background-loading':
        return fetching and key not in cache
    if operation == 'observed-stale-refetch':
        return key in stale and bool(observers)
    if operation == 'unobserved-garbage-collect':
        return not observers and not fetching
    if operation == 'resource-error-presence':
        return error is not None
    if operation == 'invalidate-one-resource':
        return list(dict.fromkeys(stale+[key]))
    if operation == 'evict-resource-key':
        return {}
    if operation == 'subscription-fanout-count':
        return len(observers)
    if operation == 'fetch-state-independent-of-data':
        return 'fetching' if fetching else 'idle'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cache-presence-not-truthiness scenario 1', solve('cache-presence-not-truthiness', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('cache-presence-not-truthiness scenario 2', solve('cache-presence-not-truthiness', ({'a':None},'a',[],[],False,'bad')), True)
check('cache-presence-not-truthiness scenario 3', solve('cache-presence-not-truthiness', ({},'a',[],['screen'],True,None)), False)
check('cache-presence-not-truthiness scenario 4', solve('cache-presence-not-truthiness', ({'a':0},'a',['a'],[],False,'')), True)
check('cache-presence-not-truthiness scenario 5', solve('cache-presence-not-truthiness', ({'b':N},'b',[],['one','two'],False,None)), True)
check('cache-presence-not-truthiness scenario 6', solve('cache-presence-not-truthiness', ({'a':[]},'a',['b'],[],True,None)), True)
check('stale-data-remains-visible scenario 1', solve('stale-data-remains-visible', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), N)
check('stale-data-remains-visible scenario 2', solve('stale-data-remains-visible', ({'a':None},'a',[],[],False,'bad')), None)
check('stale-data-remains-visible scenario 3', solve('stale-data-remains-visible', ({},'a',[],['screen'],True,None)), None)
check('stale-data-remains-visible scenario 4', solve('stale-data-remains-visible', ({'a':0},'a',['a'],[],False,'')), 0)
check('stale-data-remains-visible scenario 5', solve('stale-data-remains-visible', ({'b':N},'b',[],['one','two'],False,None)), N)
check('stale-data-remains-visible scenario 6', solve('stale-data-remains-visible', ({'a':[]},'a',['b'],[],True,None)), [])
check('initial-vs-background-loading scenario 1', solve('initial-vs-background-loading', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('initial-vs-background-loading scenario 2', solve('initial-vs-background-loading', ({'a':None},'a',[],[],False,'bad')), False)
check('initial-vs-background-loading scenario 3', solve('initial-vs-background-loading', ({},'a',[],['screen'],True,None)), True)
check('initial-vs-background-loading scenario 4', solve('initial-vs-background-loading', ({'a':0},'a',['a'],[],False,'')), False)
check('initial-vs-background-loading scenario 5', solve('initial-vs-background-loading', ({'b':N},'b',[],['one','two'],False,None)), False)
check('initial-vs-background-loading scenario 6', solve('initial-vs-background-loading', ({'a':[]},'a',['b'],[],True,None)), False)
check('observed-stale-refetch scenario 1', solve('observed-stale-refetch', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('observed-stale-refetch scenario 2', solve('observed-stale-refetch', ({'a':None},'a',[],[],False,'bad')), False)
check('observed-stale-refetch scenario 3', solve('observed-stale-refetch', ({},'a',[],['screen'],True,None)), False)
check('observed-stale-refetch scenario 4', solve('observed-stale-refetch', ({'a':0},'a',['a'],[],False,'')), False)
check('observed-stale-refetch scenario 5', solve('observed-stale-refetch', ({'b':N},'b',[],['one','two'],False,None)), False)
check('observed-stale-refetch scenario 6', solve('observed-stale-refetch', ({'a':[]},'a',['b'],[],True,None)), False)
check('unobserved-garbage-collect scenario 1', solve('unobserved-garbage-collect', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 2', solve('unobserved-garbage-collect', ({'a':None},'a',[],[],False,'bad')), True)
check('unobserved-garbage-collect scenario 3', solve('unobserved-garbage-collect', ({},'a',[],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 4', solve('unobserved-garbage-collect', ({'a':0},'a',['a'],[],False,'')), True)
check('unobserved-garbage-collect scenario 5', solve('unobserved-garbage-collect', ({'b':N},'b',[],['one','two'],False,None)), False)
check('unobserved-garbage-collect scenario 6', solve('unobserved-garbage-collect', ({'a':[]},'a',['b'],[],True,None)), False)
check('resource-error-presence scenario 1', solve('resource-error-presence', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('resource-error-presence scenario 2', solve('resource-error-presence', ({'a':None},'a',[],[],False,'bad')), True)
check('resource-error-presence scenario 3', solve('resource-error-presence', ({},'a',[],['screen'],True,None)), False)
check('resource-error-presence scenario 4', solve('resource-error-presence', ({'a':0},'a',['a'],[],False,'')), True)
check('resource-error-presence scenario 5', solve('resource-error-presence', ({'b':N},'b',[],['one','two'],False,None)), False)
check('resource-error-presence scenario 6', solve('resource-error-presence', ({'a':[]},'a',['b'],[],True,None)), False)
check('invalidate-one-resource scenario 1', solve('invalidate-one-resource', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 2', solve('invalidate-one-resource', ({'a':None},'a',[],[],False,'bad')), ['a'])
check('invalidate-one-resource scenario 3', solve('invalidate-one-resource', ({},'a',[],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 4', solve('invalidate-one-resource', ({'a':0},'a',['a'],[],False,'')), ['a'])
check('invalidate-one-resource scenario 5', solve('invalidate-one-resource', ({'b':N},'b',[],['one','two'],False,None)), ['b'])
check('invalidate-one-resource scenario 6', solve('invalidate-one-resource', ({'a':[]},'a',['b'],[],True,None)), ['b','a'])
check('evict-resource-key scenario 1', solve('evict-resource-key', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), {'b':0})
check('evict-resource-key scenario 2', solve('evict-resource-key', ({'a':None},'a',[],[],False,'bad')), {})
check('evict-resource-key scenario 3', solve('evict-resource-key', ({},'a',[],['screen'],True,None)), {})
check('evict-resource-key scenario 4', solve('evict-resource-key', ({'a':0},'a',['a'],[],False,'')), {})
check('evict-resource-key scenario 5', solve('evict-resource-key', ({'b':N},'b',[],['one','two'],False,None)), {})
check('evict-resource-key scenario 6', solve('evict-resource-key', ({'a':[]},'a',['b'],[],True,None)), {})
check('subscription-fanout-count scenario 1', solve('subscription-fanout-count', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 2', solve('subscription-fanout-count', ({'a':None},'a',[],[],False,'bad')), 0)
check('subscription-fanout-count scenario 3', solve('subscription-fanout-count', ({},'a',[],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 4', solve('subscription-fanout-count', ({'a':0},'a',['a'],[],False,'')), 0)
check('subscription-fanout-count scenario 5', solve('subscription-fanout-count', ({'b':N},'b',[],['one','two'],False,None)), 2)
check('subscription-fanout-count scenario 6', solve('subscription-fanout-count', ({'a':[]},'a',['b'],[],True,None)), 0)
check('fetch-state-independent-of-data scenario 1', solve('fetch-state-independent-of-data', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 2', solve('fetch-state-independent-of-data', ({'a':None},'a',[],[],False,'bad')), 'idle')
check('fetch-state-independent-of-data scenario 3', solve('fetch-state-independent-of-data', ({},'a',[],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 4', solve('fetch-state-independent-of-data', ({'a':0},'a',['a'],[],False,'')), 'idle')
check('fetch-state-independent-of-data scenario 5', solve('fetch-state-independent-of-data', ({'b':N},'b',[],['one','two'],False,None)), 'idle')
check('fetch-state-independent-of-data scenario 6', solve('fetch-state-independent-of-data', ({'a':[]},'a',['b'],[],True,None)), 'fetching')
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):
    cache, key, stale, observers, fetching, error = s
    if operation == 'cache-presence-not-truthiness':
        return key in cache
    if operation == 'stale-data-remains-visible':
        return cache.get(key)
    if operation == 'initial-vs-background-loading':
        return fetching and key not in cache
    if operation == 'observed-stale-refetch':
        return key in stale and bool(observers)
    if operation == 'unobserved-garbage-collect':
        return not observers and not fetching
    if operation == 'resource-error-presence':
        return error is not None
    if operation == 'invalidate-one-resource':
        return list(dict.fromkeys(stale+[key]))
    if operation == 'evict-resource-key':
        return cache
    if operation == 'subscription-fanout-count':
        return len(observers)
    if operation == 'fetch-state-independent-of-data':
        return 'fetching' if fetching else 'idle'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cache-presence-not-truthiness scenario 1', solve('cache-presence-not-truthiness', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('cache-presence-not-truthiness scenario 2', solve('cache-presence-not-truthiness', ({'a':None},'a',[],[],False,'bad')), True)
check('cache-presence-not-truthiness scenario 3', solve('cache-presence-not-truthiness', ({},'a',[],['screen'],True,None)), False)
check('cache-presence-not-truthiness scenario 4', solve('cache-presence-not-truthiness', ({'a':0},'a',['a'],[],False,'')), True)
check('cache-presence-not-truthiness scenario 5', solve('cache-presence-not-truthiness', ({'b':N},'b',[],['one','two'],False,None)), True)
check('cache-presence-not-truthiness scenario 6', solve('cache-presence-not-truthiness', ({'a':[]},'a',['b'],[],True,None)), True)
check('stale-data-remains-visible scenario 1', solve('stale-data-remains-visible', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), N)
check('stale-data-remains-visible scenario 2', solve('stale-data-remains-visible', ({'a':None},'a',[],[],False,'bad')), None)
check('stale-data-remains-visible scenario 3', solve('stale-data-remains-visible', ({},'a',[],['screen'],True,None)), None)
check('stale-data-remains-visible scenario 4', solve('stale-data-remains-visible', ({'a':0},'a',['a'],[],False,'')), 0)
check('stale-data-remains-visible scenario 5', solve('stale-data-remains-visible', ({'b':N},'b',[],['one','two'],False,None)), N)
check('stale-data-remains-visible scenario 6', solve('stale-data-remains-visible', ({'a':[]},'a',['b'],[],True,None)), [])
check('initial-vs-background-loading scenario 1', solve('initial-vs-background-loading', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('initial-vs-background-loading scenario 2', solve('initial-vs-background-loading', ({'a':None},'a',[],[],False,'bad')), False)
check('initial-vs-background-loading scenario 3', solve('initial-vs-background-loading', ({},'a',[],['screen'],True,None)), True)
check('initial-vs-background-loading scenario 4', solve('initial-vs-background-loading', ({'a':0},'a',['a'],[],False,'')), False)
check('initial-vs-background-loading scenario 5', solve('initial-vs-background-loading', ({'b':N},'b',[],['one','two'],False,None)), False)
check('initial-vs-background-loading scenario 6', solve('initial-vs-background-loading', ({'a':[]},'a',['b'],[],True,None)), False)
check('observed-stale-refetch scenario 1', solve('observed-stale-refetch', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('observed-stale-refetch scenario 2', solve('observed-stale-refetch', ({'a':None},'a',[],[],False,'bad')), False)
check('observed-stale-refetch scenario 3', solve('observed-stale-refetch', ({},'a',[],['screen'],True,None)), False)
check('observed-stale-refetch scenario 4', solve('observed-stale-refetch', ({'a':0},'a',['a'],[],False,'')), False)
check('observed-stale-refetch scenario 5', solve('observed-stale-refetch', ({'b':N},'b',[],['one','two'],False,None)), False)
check('observed-stale-refetch scenario 6', solve('observed-stale-refetch', ({'a':[]},'a',['b'],[],True,None)), False)
check('unobserved-garbage-collect scenario 1', solve('unobserved-garbage-collect', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 2', solve('unobserved-garbage-collect', ({'a':None},'a',[],[],False,'bad')), True)
check('unobserved-garbage-collect scenario 3', solve('unobserved-garbage-collect', ({},'a',[],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 4', solve('unobserved-garbage-collect', ({'a':0},'a',['a'],[],False,'')), True)
check('unobserved-garbage-collect scenario 5', solve('unobserved-garbage-collect', ({'b':N},'b',[],['one','two'],False,None)), False)
check('unobserved-garbage-collect scenario 6', solve('unobserved-garbage-collect', ({'a':[]},'a',['b'],[],True,None)), False)
check('resource-error-presence scenario 1', solve('resource-error-presence', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('resource-error-presence scenario 2', solve('resource-error-presence', ({'a':None},'a',[],[],False,'bad')), True)
check('resource-error-presence scenario 3', solve('resource-error-presence', ({},'a',[],['screen'],True,None)), False)
check('resource-error-presence scenario 4', solve('resource-error-presence', ({'a':0},'a',['a'],[],False,'')), True)
check('resource-error-presence scenario 5', solve('resource-error-presence', ({'b':N},'b',[],['one','two'],False,None)), False)
check('resource-error-presence scenario 6', solve('resource-error-presence', ({'a':[]},'a',['b'],[],True,None)), False)
check('invalidate-one-resource scenario 1', solve('invalidate-one-resource', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 2', solve('invalidate-one-resource', ({'a':None},'a',[],[],False,'bad')), ['a'])
check('invalidate-one-resource scenario 3', solve('invalidate-one-resource', ({},'a',[],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 4', solve('invalidate-one-resource', ({'a':0},'a',['a'],[],False,'')), ['a'])
check('invalidate-one-resource scenario 5', solve('invalidate-one-resource', ({'b':N},'b',[],['one','two'],False,None)), ['b'])
check('invalidate-one-resource scenario 6', solve('invalidate-one-resource', ({'a':[]},'a',['b'],[],True,None)), ['b','a'])
check('evict-resource-key scenario 1', solve('evict-resource-key', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), {'b':0})
check('evict-resource-key scenario 2', solve('evict-resource-key', ({'a':None},'a',[],[],False,'bad')), {})
check('evict-resource-key scenario 3', solve('evict-resource-key', ({},'a',[],['screen'],True,None)), {})
check('evict-resource-key scenario 4', solve('evict-resource-key', ({'a':0},'a',['a'],[],False,'')), {})
check('evict-resource-key scenario 5', solve('evict-resource-key', ({'b':N},'b',[],['one','two'],False,None)), {})
check('evict-resource-key scenario 6', solve('evict-resource-key', ({'a':[]},'a',['b'],[],True,None)), {})
check('subscription-fanout-count scenario 1', solve('subscription-fanout-count', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 2', solve('subscription-fanout-count', ({'a':None},'a',[],[],False,'bad')), 0)
check('subscription-fanout-count scenario 3', solve('subscription-fanout-count', ({},'a',[],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 4', solve('subscription-fanout-count', ({'a':0},'a',['a'],[],False,'')), 0)
check('subscription-fanout-count scenario 5', solve('subscription-fanout-count', ({'b':N},'b',[],['one','two'],False,None)), 2)
check('subscription-fanout-count scenario 6', solve('subscription-fanout-count', ({'a':[]},'a',['b'],[],True,None)), 0)
check('fetch-state-independent-of-data scenario 1', solve('fetch-state-independent-of-data', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 2', solve('fetch-state-independent-of-data', ({'a':None},'a',[],[],False,'bad')), 'idle')
check('fetch-state-independent-of-data scenario 3', solve('fetch-state-independent-of-data', ({},'a',[],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 4', solve('fetch-state-independent-of-data', ({'a':0},'a',['a'],[],False,'')), 'idle')
check('fetch-state-independent-of-data scenario 5', solve('fetch-state-independent-of-data', ({'b':N},'b',[],['one','two'],False,None)), 'idle')
check('fetch-state-independent-of-data scenario 6', solve('fetch-state-independent-of-data', ({'a':[]},'a',['b'],[],True,None)), 'fetching')
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:
Evict resource key.

Client cache presence is independent of payload truthiness. Stale data remains visible during background refresh; first-load status requires absent data. Observers retain resources, and invalidation is idempotent per key. Operation evict-resource-key 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):
    cache, key, stale, observers, fetching, error = s
    if operation == 'cache-presence-not-truthiness':
        return key in cache
    if operation == 'stale-data-remains-visible':
        return cache.get(key)
    if operation == 'initial-vs-background-loading':
        return fetching and key not in cache
    if operation == 'observed-stale-refetch':
        return key in stale and bool(observers)
    if operation == 'unobserved-garbage-collect':
        return not observers and not fetching
    if operation == 'resource-error-presence':
        return error is not None
    if operation == 'invalidate-one-resource':
        return list(dict.fromkeys(stale+[key]))
    if operation == 'evict-resource-key':
        return {k:v for k,v in cache.items() if k!=key}
    if operation == 'subscription-fanout-count':
        return len(observers)
    if operation == 'fetch-state-independent-of-data':
        return 'idle' if key in cache else 'fetching'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cache-presence-not-truthiness scenario 1', solve('cache-presence-not-truthiness', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('cache-presence-not-truthiness scenario 2', solve('cache-presence-not-truthiness', ({'a':None},'a',[],[],False,'bad')), True)
check('cache-presence-not-truthiness scenario 3', solve('cache-presence-not-truthiness', ({},'a',[],['screen'],True,None)), False)
check('cache-presence-not-truthiness scenario 4', solve('cache-presence-not-truthiness', ({'a':0},'a',['a'],[],False,'')), True)
check('cache-presence-not-truthiness scenario 5', solve('cache-presence-not-truthiness', ({'b':N},'b',[],['one','two'],False,None)), True)
check('cache-presence-not-truthiness scenario 6', solve('cache-presence-not-truthiness', ({'a':[]},'a',['b'],[],True,None)), True)
check('stale-data-remains-visible scenario 1', solve('stale-data-remains-visible', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), N)
check('stale-data-remains-visible scenario 2', solve('stale-data-remains-visible', ({'a':None},'a',[],[],False,'bad')), None)
check('stale-data-remains-visible scenario 3', solve('stale-data-remains-visible', ({},'a',[],['screen'],True,None)), None)
check('stale-data-remains-visible scenario 4', solve('stale-data-remains-visible', ({'a':0},'a',['a'],[],False,'')), 0)
check('stale-data-remains-visible scenario 5', solve('stale-data-remains-visible', ({'b':N},'b',[],['one','two'],False,None)), N)
check('stale-data-remains-visible scenario 6', solve('stale-data-remains-visible', ({'a':[]},'a',['b'],[],True,None)), [])
check('initial-vs-background-loading scenario 1', solve('initial-vs-background-loading', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('initial-vs-background-loading scenario 2', solve('initial-vs-background-loading', ({'a':None},'a',[],[],False,'bad')), False)
check('initial-vs-background-loading scenario 3', solve('initial-vs-background-loading', ({},'a',[],['screen'],True,None)), True)
check('initial-vs-background-loading scenario 4', solve('initial-vs-background-loading', ({'a':0},'a',['a'],[],False,'')), False)
check('initial-vs-background-loading scenario 5', solve('initial-vs-background-loading', ({'b':N},'b',[],['one','two'],False,None)), False)
check('initial-vs-background-loading scenario 6', solve('initial-vs-background-loading', ({'a':[]},'a',['b'],[],True,None)), False)
check('observed-stale-refetch scenario 1', solve('observed-stale-refetch', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('observed-stale-refetch scenario 2', solve('observed-stale-refetch', ({'a':None},'a',[],[],False,'bad')), False)
check('observed-stale-refetch scenario 3', solve('observed-stale-refetch', ({},'a',[],['screen'],True,None)), False)
check('observed-stale-refetch scenario 4', solve('observed-stale-refetch', ({'a':0},'a',['a'],[],False,'')), False)
check('observed-stale-refetch scenario 5', solve('observed-stale-refetch', ({'b':N},'b',[],['one','two'],False,None)), False)
check('observed-stale-refetch scenario 6', solve('observed-stale-refetch', ({'a':[]},'a',['b'],[],True,None)), False)
check('unobserved-garbage-collect scenario 1', solve('unobserved-garbage-collect', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 2', solve('unobserved-garbage-collect', ({'a':None},'a',[],[],False,'bad')), True)
check('unobserved-garbage-collect scenario 3', solve('unobserved-garbage-collect', ({},'a',[],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 4', solve('unobserved-garbage-collect', ({'a':0},'a',['a'],[],False,'')), True)
check('unobserved-garbage-collect scenario 5', solve('unobserved-garbage-collect', ({'b':N},'b',[],['one','two'],False,None)), False)
check('unobserved-garbage-collect scenario 6', solve('unobserved-garbage-collect', ({'a':[]},'a',['b'],[],True,None)), False)
check('resource-error-presence scenario 1', solve('resource-error-presence', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('resource-error-presence scenario 2', solve('resource-error-presence', ({'a':None},'a',[],[],False,'bad')), True)
check('resource-error-presence scenario 3', solve('resource-error-presence', ({},'a',[],['screen'],True,None)), False)
check('resource-error-presence scenario 4', solve('resource-error-presence', ({'a':0},'a',['a'],[],False,'')), True)
check('resource-error-presence scenario 5', solve('resource-error-presence', ({'b':N},'b',[],['one','two'],False,None)), False)
check('resource-error-presence scenario 6', solve('resource-error-presence', ({'a':[]},'a',['b'],[],True,None)), False)
check('invalidate-one-resource scenario 1', solve('invalidate-one-resource', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 2', solve('invalidate-one-resource', ({'a':None},'a',[],[],False,'bad')), ['a'])
check('invalidate-one-resource scenario 3', solve('invalidate-one-resource', ({},'a',[],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 4', solve('invalidate-one-resource', ({'a':0},'a',['a'],[],False,'')), ['a'])
check('invalidate-one-resource scenario 5', solve('invalidate-one-resource', ({'b':N},'b',[],['one','two'],False,None)), ['b'])
check('invalidate-one-resource scenario 6', solve('invalidate-one-resource', ({'a':[]},'a',['b'],[],True,None)), ['b','a'])
check('evict-resource-key scenario 1', solve('evict-resource-key', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), {'b':0})
check('evict-resource-key scenario 2', solve('evict-resource-key', ({'a':None},'a',[],[],False,'bad')), {})
check('evict-resource-key scenario 3', solve('evict-resource-key', ({},'a',[],['screen'],True,None)), {})
check('evict-resource-key scenario 4', solve('evict-resource-key', ({'a':0},'a',['a'],[],False,'')), {})
check('evict-resource-key scenario 5', solve('evict-resource-key', ({'b':N},'b',[],['one','two'],False,None)), {})
check('evict-resource-key scenario 6', solve('evict-resource-key', ({'a':[]},'a',['b'],[],True,None)), {})
check('subscription-fanout-count scenario 1', solve('subscription-fanout-count', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 2', solve('subscription-fanout-count', ({'a':None},'a',[],[],False,'bad')), 0)
check('subscription-fanout-count scenario 3', solve('subscription-fanout-count', ({},'a',[],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 4', solve('subscription-fanout-count', ({'a':0},'a',['a'],[],False,'')), 0)
check('subscription-fanout-count scenario 5', solve('subscription-fanout-count', ({'b':N},'b',[],['one','two'],False,None)), 2)
check('subscription-fanout-count scenario 6', solve('subscription-fanout-count', ({'a':[]},'a',['b'],[],True,None)), 0)
check('fetch-state-independent-of-data scenario 1', solve('fetch-state-independent-of-data', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 2', solve('fetch-state-independent-of-data', ({'a':None},'a',[],[],False,'bad')), 'idle')
check('fetch-state-independent-of-data scenario 3', solve('fetch-state-independent-of-data', ({},'a',[],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 4', solve('fetch-state-independent-of-data', ({'a':0},'a',['a'],[],False,'')), 'idle')
check('fetch-state-independent-of-data scenario 5', solve('fetch-state-independent-of-data', ({'b':N},'b',[],['one','two'],False,None)), 'idle')
check('fetch-state-independent-of-data scenario 6', solve('fetch-state-independent-of-data', ({'a':[]},'a',['b'],[],True,None)), 'fetching')
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):
    cache, key, stale, observers, fetching, error = s
    if operation == 'cache-presence-not-truthiness':
        return key in cache
    if operation == 'stale-data-remains-visible':
        return cache.get(key)
    if operation == 'initial-vs-background-loading':
        return fetching and key not in cache
    if operation == 'observed-stale-refetch':
        return key in stale and bool(observers)
    if operation == 'unobserved-garbage-collect':
        return not observers and not fetching
    if operation == 'resource-error-presence':
        return error is not None
    if operation == 'invalidate-one-resource':
        return list(dict.fromkeys(stale+[key]))
    if operation == 'evict-resource-key':
        return {k:v for k,v in cache.items() if k!=key}
    if operation == 'subscription-fanout-count':
        return len(observers)
    if operation == 'fetch-state-independent-of-data':
        return 'fetching' if fetching and cache.get(key) else 'idle'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('cache-presence-not-truthiness scenario 1', solve('cache-presence-not-truthiness', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('cache-presence-not-truthiness scenario 2', solve('cache-presence-not-truthiness', ({'a':None},'a',[],[],False,'bad')), True)
check('cache-presence-not-truthiness scenario 3', solve('cache-presence-not-truthiness', ({},'a',[],['screen'],True,None)), False)
check('cache-presence-not-truthiness scenario 4', solve('cache-presence-not-truthiness', ({'a':0},'a',['a'],[],False,'')), True)
check('cache-presence-not-truthiness scenario 5', solve('cache-presence-not-truthiness', ({'b':N},'b',[],['one','two'],False,None)), True)
check('cache-presence-not-truthiness scenario 6', solve('cache-presence-not-truthiness', ({'a':[]},'a',['b'],[],True,None)), True)
check('stale-data-remains-visible scenario 1', solve('stale-data-remains-visible', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), N)
check('stale-data-remains-visible scenario 2', solve('stale-data-remains-visible', ({'a':None},'a',[],[],False,'bad')), None)
check('stale-data-remains-visible scenario 3', solve('stale-data-remains-visible', ({},'a',[],['screen'],True,None)), None)
check('stale-data-remains-visible scenario 4', solve('stale-data-remains-visible', ({'a':0},'a',['a'],[],False,'')), 0)
check('stale-data-remains-visible scenario 5', solve('stale-data-remains-visible', ({'b':N},'b',[],['one','two'],False,None)), N)
check('stale-data-remains-visible scenario 6', solve('stale-data-remains-visible', ({'a':[]},'a',['b'],[],True,None)), [])
check('initial-vs-background-loading scenario 1', solve('initial-vs-background-loading', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('initial-vs-background-loading scenario 2', solve('initial-vs-background-loading', ({'a':None},'a',[],[],False,'bad')), False)
check('initial-vs-background-loading scenario 3', solve('initial-vs-background-loading', ({},'a',[],['screen'],True,None)), True)
check('initial-vs-background-loading scenario 4', solve('initial-vs-background-loading', ({'a':0},'a',['a'],[],False,'')), False)
check('initial-vs-background-loading scenario 5', solve('initial-vs-background-loading', ({'b':N},'b',[],['one','two'],False,None)), False)
check('initial-vs-background-loading scenario 6', solve('initial-vs-background-loading', ({'a':[]},'a',['b'],[],True,None)), False)
check('observed-stale-refetch scenario 1', solve('observed-stale-refetch', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), True)
check('observed-stale-refetch scenario 2', solve('observed-stale-refetch', ({'a':None},'a',[],[],False,'bad')), False)
check('observed-stale-refetch scenario 3', solve('observed-stale-refetch', ({},'a',[],['screen'],True,None)), False)
check('observed-stale-refetch scenario 4', solve('observed-stale-refetch', ({'a':0},'a',['a'],[],False,'')), False)
check('observed-stale-refetch scenario 5', solve('observed-stale-refetch', ({'b':N},'b',[],['one','two'],False,None)), False)
check('observed-stale-refetch scenario 6', solve('observed-stale-refetch', ({'a':[]},'a',['b'],[],True,None)), False)
check('unobserved-garbage-collect scenario 1', solve('unobserved-garbage-collect', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 2', solve('unobserved-garbage-collect', ({'a':None},'a',[],[],False,'bad')), True)
check('unobserved-garbage-collect scenario 3', solve('unobserved-garbage-collect', ({},'a',[],['screen'],True,None)), False)
check('unobserved-garbage-collect scenario 4', solve('unobserved-garbage-collect', ({'a':0},'a',['a'],[],False,'')), True)
check('unobserved-garbage-collect scenario 5', solve('unobserved-garbage-collect', ({'b':N},'b',[],['one','two'],False,None)), False)
check('unobserved-garbage-collect scenario 6', solve('unobserved-garbage-collect', ({'a':[]},'a',['b'],[],True,None)), False)
check('resource-error-presence scenario 1', solve('resource-error-presence', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), False)
check('resource-error-presence scenario 2', solve('resource-error-presence', ({'a':None},'a',[],[],False,'bad')), True)
check('resource-error-presence scenario 3', solve('resource-error-presence', ({},'a',[],['screen'],True,None)), False)
check('resource-error-presence scenario 4', solve('resource-error-presence', ({'a':0},'a',['a'],[],False,'')), True)
check('resource-error-presence scenario 5', solve('resource-error-presence', ({'b':N},'b',[],['one','two'],False,None)), False)
check('resource-error-presence scenario 6', solve('resource-error-presence', ({'a':[]},'a',['b'],[],True,None)), False)
check('invalidate-one-resource scenario 1', solve('invalidate-one-resource', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 2', solve('invalidate-one-resource', ({'a':None},'a',[],[],False,'bad')), ['a'])
check('invalidate-one-resource scenario 3', solve('invalidate-one-resource', ({},'a',[],['screen'],True,None)), ['a'])
check('invalidate-one-resource scenario 4', solve('invalidate-one-resource', ({'a':0},'a',['a'],[],False,'')), ['a'])
check('invalidate-one-resource scenario 5', solve('invalidate-one-resource', ({'b':N},'b',[],['one','two'],False,None)), ['b'])
check('invalidate-one-resource scenario 6', solve('invalidate-one-resource', ({'a':[]},'a',['b'],[],True,None)), ['b','a'])
check('evict-resource-key scenario 1', solve('evict-resource-key', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), {'b':0})
check('evict-resource-key scenario 2', solve('evict-resource-key', ({'a':None},'a',[],[],False,'bad')), {})
check('evict-resource-key scenario 3', solve('evict-resource-key', ({},'a',[],['screen'],True,None)), {})
check('evict-resource-key scenario 4', solve('evict-resource-key', ({'a':0},'a',['a'],[],False,'')), {})
check('evict-resource-key scenario 5', solve('evict-resource-key', ({'b':N},'b',[],['one','two'],False,None)), {})
check('evict-resource-key scenario 6', solve('evict-resource-key', ({'a':[]},'a',['b'],[],True,None)), {})
check('subscription-fanout-count scenario 1', solve('subscription-fanout-count', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 2', solve('subscription-fanout-count', ({'a':None},'a',[],[],False,'bad')), 0)
check('subscription-fanout-count scenario 3', solve('subscription-fanout-count', ({},'a',[],['screen'],True,None)), 1)
check('subscription-fanout-count scenario 4', solve('subscription-fanout-count', ({'a':0},'a',['a'],[],False,'')), 0)
check('subscription-fanout-count scenario 5', solve('subscription-fanout-count', ({'b':N},'b',[],['one','two'],False,None)), 2)
check('subscription-fanout-count scenario 6', solve('subscription-fanout-count', ({'a':[]},'a',['b'],[],True,None)), 0)
check('fetch-state-independent-of-data scenario 1', solve('fetch-state-independent-of-data', ({'a':N,'b':0},'a',['a'],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 2', solve('fetch-state-independent-of-data', ({'a':None},'a',[],[],False,'bad')), 'idle')
check('fetch-state-independent-of-data scenario 3', solve('fetch-state-independent-of-data', ({},'a',[],['screen'],True,None)), 'fetching')
check('fetch-state-independent-of-data scenario 4', solve('fetch-state-independent-of-data', ({'a':0},'a',['a'],[],False,'')), 'idle')
check('fetch-state-independent-of-data scenario 5', solve('fetch-state-independent-of-data', ({'b':N},'b',[],['one','two'],False,None)), 'idle')
check('fetch-state-independent-of-data scenario 6', solve('fetch-state-independent-of-data', ({'a':[]},'a',['b'],[],True,None)), 'fetching')
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:
Fetch state independent of data.

Client cache presence is independent of payload truthiness. Stale data remains visible during background refresh; first-load status requires absent data. Observers retain resources, and invalidation is idempotent per key. Operation fetch-state-independent-of-data has the six explicit input/output oracles below.

split: open-access