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

N = 1
observations = []
def solve(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'ready', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'empty', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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:
The cache-found event leaves a notification in ready instead of cached-unverified.

Notification inbox initial restoration is a bounded visual-notification workflow with mutable policy state {'rows': ['cached'], 'version': 3, 'warning': False}. Its default transition relation is {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}; domain inputs can suppress or redirect transitions and update policy fields, as specified in solve. Different-generation events are inert. Batches apply in order. Optional observe returns the selected policy field alongside the phase.

split: open-access


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

N = 1
observations = []
def solve(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'empty', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'ready', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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:
The cache-missing event leaves a notification in empty instead of fetching.

Notification inbox initial restoration is a bounded visual-notification workflow with mutable policy state {'rows': ['cached'], 'version': 3, 'warning': False}. Its default transition relation is {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}; domain inputs can suppress or redirect transitions and update policy fields, as specified in solve. Different-generation events are inert. Batches apply in order. Optional observe returns the selected policy field alongside the phase.

split: open-access


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

N = 1
observations = []
def solve(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'placeholder', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'ready', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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:
The refresh-start event leaves a notification in placeholder instead of refreshing-cache.

Notification inbox initial restoration is a bounded visual-notification workflow with mutable policy state {'rows': ['cached'], 'version': 3, 'warning': False}. Its default transition relation is {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}; domain inputs can suppress or redirect transitions and update policy fields, as specified in solve. Different-generation events are inert. Batches apply in order. Optional observe returns the selected policy field alongside the phase.

split: open-access


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

N = 1
observations = []
def solve(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'empty', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'cached-unverified', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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:
The fresh-nonempty event leaves a notification in empty instead of ready.

Notification inbox initial restoration is a bounded visual-notification workflow with mutable policy state {'rows': ['cached'], 'version': 3, 'warning': False}. Its default transition relation is {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}; domain inputs can suppress or redirect transitions and update policy fields, as specified in solve. Different-generation events are inert. Batches apply in order. Optional observe returns the selected policy field alongside the phase.

split: open-access


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

N = 1
observations = []
def solve(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'ready', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'cached-unverified', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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:
The fresh-empty event leaves a notification in ready instead of empty.

Notification inbox initial restoration is a bounded visual-notification workflow with mutable policy state {'rows': ['cached'], 'version': 3, 'warning': False}. Its default transition relation is {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}; domain inputs can suppress or redirect transitions and update policy fields, as specified in solve. Different-generation events are inert. Batches apply in order. Optional observe returns the selected policy field alongside the phase.

split: open-access


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

N = 1
observations = []
def solve(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'empty', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'ready', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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:
The refresh-error event leaves a notification in empty instead of stale-warning.

Notification inbox initial restoration is a bounded visual-notification workflow with mutable policy state {'rows': ['cached'], 'version': 3, 'warning': False}. Its default transition relation is {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}; domain inputs can suppress or redirect transitions and update policy fields, as specified in solve. Different-generation events are inert. Batches apply in order. Optional observe returns the selected policy field alongside the phase.

split: open-access


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

N = 1
observations = []
def solve(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'empty', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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(initial, events, generation, payload=None, observe=None):
    table = {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'placeholder', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}
    data = json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})) if payload is None else {**json.loads(json.dumps({'rows': ['cached'], 'version': 3, 'warning': False})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('fresh-nonempty','fresh-empty'):
                if arg.get('version',data['version']) < data['version']: event = 'unknown-event'
                else:
                    data['version'] = arg.get('version',data['version'])
                    data['rows'] = arg.get('rows',[] if event == 'fresh-empty' else ['fresh'])[:]
            if event == 'cache-found' and 'rows' in arg: data['rows'] = arg['rows'][:]
            state = table.get((state, event), state)
            if state == 'stale-warning': data['warning'] = True
            if state in ('ready','empty'): data['warning'] = False
            if state == 'empty': data['rows'] = []
    return {'phase': state, 'value': data[observe]} if observe else state
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('placeholder / cache-found', solve('placeholder', [('cache-found', N)], N), 'cached-unverified')
check('placeholder / cache-missing', solve('placeholder', [('cache-missing', N)], N), 'fetching')
check('cached-unverified / refresh-start', solve('cached-unverified', [('refresh-start', N)], N), 'refreshing-cache')
check('refreshing-cache / fresh-nonempty', solve('refreshing-cache', [('fresh-nonempty', N)], N), 'ready')
check('refreshing-cache / fresh-empty', solve('refreshing-cache', [('fresh-empty', N)], N), 'empty')
check('refreshing-cache / refresh-error', solve('refreshing-cache', [('refresh-error', N)], N), 'stale-warning')
check('fetching / fresh-nonempty', solve('fetching', [('fresh-nonempty', N)], N), 'ready')
check('fetching / fresh-empty', solve('fetching', [('fresh-empty', N)], N), 'empty')
check('fetching / refresh-error', solve('fetching', [('refresh-error', N)], N), 'load-error')
check('stale-warning / retry-refresh', solve('stale-warning', [('retry-refresh', N)], N), 'refreshing-cache')
check('older notification incarnation', solve('placeholder', [('cache-found', N - 1)], N), 'placeholder')
check('future notification incarnation', solve('placeholder', [('cache-found', N + 1)], N), 'placeholder')
check('unknown event is inert', solve('placeholder', [('unknown-event', N)], N), 'placeholder')
check('empty delivery batch', solve('placeholder', [], N), 'placeholder')
check('N stale deliveries before current delivery', solve('placeholder', [('cache-found', N - 1)] * N + [('cache-found', N)], N), 'cached-unverified')
check('trace cache-found then refresh-start', solve('placeholder', [('cache-found', N), ('refresh-start', N)], N), 'refreshing-cache')
check('trace cache-missing then fresh-nonempty', solve('placeholder', [('cache-missing', N), ('fresh-nonempty', N)], N), 'ready')
check('trace cache-missing then fresh-empty', solve('placeholder', [('cache-missing', N), ('fresh-empty', N)], N), 'empty')
check('trace cache-missing then refresh-error', solve('placeholder', [('cache-missing', N), ('refresh-error', N)], N), 'load-error')
check('trace refresh-start then fresh-nonempty', solve('cached-unverified', [('refresh-start', N), ('fresh-nonempty', N)], N), 'ready')
check('trace refresh-start then fresh-empty', solve('cached-unverified', [('refresh-start', N), ('fresh-empty', N)], N), 'empty')
check('trace refresh-start then refresh-error', solve('cached-unverified', [('refresh-start', N), ('refresh-error', N)], N), 'stale-warning')
check('trace refresh-error then retry-refresh', solve('refreshing-cache', [('refresh-error', N), ('retry-refresh', N)], N), 'refreshing-cache')
check('trace retry-refresh then fresh-nonempty', solve('stale-warning', [('retry-refresh', N), ('fresh-nonempty', N)], N), 'ready')
check('trace retry-refresh then fresh-empty', solve('stale-warning', [('retry-refresh', N), ('fresh-empty', N)], N), 'empty')
check('trace retry-refresh then refresh-error', solve('stale-warning', [('retry-refresh', N), ('refresh-error', N)], N), 'stale-warning')
check('domain state regression 1: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 2, 'rows': ['old']})], N, {}, 'rows'), {'phase': 'refreshing-cache', 'value': ['cached']})
check('domain state regression 2: rows', solve('refreshing-cache', [('fresh-nonempty', N, {'version': 4, 'rows': ['new']})], N, {}, 'rows'), {'phase': 'ready', 'value': ['new']})
check('domain state regression 3: rows', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['cached']})
check('domain state regression 4: warning', solve('refreshing-cache', [('refresh-error', N, {})], N, {}, 'warning'), {'phase': 'stale-warning', 'value': True})
check('domain state regression 5: rows', solve('refreshing-cache', [('fresh-empty', N, {})], N, {}, 'rows'), {'phase': 'empty', 'value': []})
check('domain state regression 6: rows', solve('placeholder', [('cache-found', N, {'rows': ['a', 'b']})], N, {}, 'rows'), {'phase': 'cached-unverified', 'value': ['a', 'b']})
check('domain state regression 7: rows', solve('placeholder', [('cache-found', N, {'rows': ['saved']}), ('refresh-start', N, {}), ('refresh-error', N, {})], N, {}, 'rows'), {'phase': 'stale-warning', 'value': ['saved']})
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:
The fresh-nonempty event leaves a notification in empty instead of ready.

Notification inbox initial restoration is a bounded visual-notification workflow with mutable policy state {'rows': ['cached'], 'version': 3, 'warning': False}. Its default transition relation is {('placeholder', 'cache-found'): 'cached-unverified', ('placeholder', 'cache-missing'): 'fetching', ('cached-unverified', 'refresh-start'): 'refreshing-cache', ('refreshing-cache', 'fresh-nonempty'): 'ready', ('refreshing-cache', 'fresh-empty'): 'empty', ('refreshing-cache', 'refresh-error'): 'stale-warning', ('fetching', 'fresh-nonempty'): 'ready', ('fetching', 'fresh-empty'): 'empty', ('fetching', 'refresh-error'): 'load-error', ('stale-warning', 'retry-refresh'): 'refreshing-cache'}; domain inputs can suppress or redirect transitions and update policy fields, as specified in solve. Different-generation events are inert. Batches apply in order. Optional observe returns the selected policy field alongside the phase.

split: open-access