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 = {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-read', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}
    data = json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False})) if payload is None else {**json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': 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 == 'ack-revision' and arg.get('revision',data['current']) != data['current']: event = 'unknown-event'
            if event == 'revision-three-arrives': data['current'] = 3
            state = table.get((state, event), state)
            if state in ('revision-two-preview','revision-three-preview'): data['preview'] = data['current']
            if state == 'revision-two-read': data['ack'] = 2
            if state == 'revision-three-read': data['ack'] = 3
            if state == 'withdrawn':
                data['withdrawn'] = True
                data['preview'] = None
    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('revision-one-read / revision-two-arrives', solve('revision-one-read', [('revision-two-arrives', N)], N), 'revision-two-unread')
check('revision-two-unread / open-revision', solve('revision-two-unread', [('open-revision', N)], N), 'revision-two-preview')
check('revision-two-preview / ack-revision', solve('revision-two-preview', [('ack-revision', N)], N), 'revision-two-read')
check('revision-two-preview / revision-three-arrives', solve('revision-two-preview', [('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('revision-three-pending-review / accept-update', solve('revision-three-pending-review', [('accept-update', N)], N), 'revision-three-preview')
check('revision-three-preview / ack-revision', solve('revision-three-preview', [('ack-revision', N)], N), 'revision-three-read')
check('revision-three-read / late-revision-two', solve('revision-three-read', [('late-revision-two', N)], N), 'revision-three-read')
check('revision-three-pending-review / close-preview', solve('revision-three-pending-review', [('close-preview', N)], N), 'revision-three-unread')
check('revision-three-unread / open-revision', solve('revision-three-unread', [('open-revision', N)], N), 'revision-three-preview')
check('revision-two-unread / revision-withdrawn', solve('revision-two-unread', [('revision-withdrawn', N)], N), 'withdrawn')
check('older notification incarnation', solve('revision-one-read', [('revision-two-arrives', N - 1)], N), 'revision-one-read')
check('future notification incarnation', solve('revision-one-read', [('revision-two-arrives', N + 1)], N), 'revision-one-read')
check('unknown event is inert', solve('revision-one-read', [('unknown-event', N)], N), 'revision-one-read')
check('empty delivery batch', solve('revision-one-read', [], N), 'revision-one-read')
check('N stale deliveries before current delivery', solve('revision-one-read', [('revision-two-arrives', N - 1)] * N + [('revision-two-arrives', N)], N), 'revision-two-unread')
check('trace revision-two-arrives then open-revision', solve('revision-one-read', [('revision-two-arrives', N), ('open-revision', N)], N), 'revision-two-preview')
check('trace revision-two-arrives then revision-withdrawn', solve('revision-one-read', [('revision-two-arrives', N), ('revision-withdrawn', N)], N), 'withdrawn')
check('trace open-revision then ack-revision', solve('revision-two-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-two-read')
check('trace open-revision then revision-three-arrives', solve('revision-two-unread', [('open-revision', N), ('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('trace revision-three-arrives then accept-update', solve('revision-two-preview', [('revision-three-arrives', N), ('accept-update', N)], N), 'revision-three-preview')
check('trace revision-three-arrives then close-preview', solve('revision-two-preview', [('revision-three-arrives', N), ('close-preview', N)], N), 'revision-three-unread')
check('trace accept-update then ack-revision', solve('revision-three-pending-review', [('accept-update', N), ('ack-revision', N)], N), 'revision-three-read')
check('trace ack-revision then late-revision-two', solve('revision-three-preview', [('ack-revision', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace late-revision-two then late-revision-two', solve('revision-three-read', [('late-revision-two', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace close-preview then open-revision', solve('revision-three-pending-review', [('close-preview', N), ('open-revision', N)], N), 'revision-three-preview')
check('trace open-revision then ack-revision', solve('revision-three-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-three-read')
check('domain state regression 1: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 1})], N, {}, 'ack'), {'phase': 'revision-two-preview', 'value': 1})
check('domain state regression 2: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 2})], N, {}, 'ack'), {'phase': 'revision-two-read', 'value': 2})
check('domain state regression 3: preview', solve('revision-two-preview', [('revision-three-arrives', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'revision-three-pending-review', 'value': 2})
check('domain state regression 4: preview', solve('revision-three-pending-review', [('accept-update', N, {})], N, {'current': 3, 'preview': 2}, 'preview'), {'phase': 'revision-three-preview', 'value': 3})
check('domain state regression 5: current', solve('revision-three-read', [('late-revision-two', N, {})], N, {'current': 3, 'ack': 3}, 'current'), {'phase': 'revision-three-read', 'value': 3})
check('domain state regression 6: preview', solve('revision-two-unread', [('revision-withdrawn', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'withdrawn', 'value': None})
check('domain state regression 7: ack', solve('revision-two-preview', [('revision-three-arrives', N, {}), ('accept-update', N, {}), ('ack-revision', N, {'revision': 2}), ('ack-revision', N, {'revision': 3})], N, {}, 'ack'), {'phase': 'revision-three-read', 'value': 3})
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 = {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-two-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}
    data = json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False})) if payload is None else {**json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': 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 == 'ack-revision' and arg.get('revision',data['current']) != data['current']: event = 'unknown-event'
            if event == 'revision-three-arrives': data['current'] = 3
            state = table.get((state, event), state)
            if state in ('revision-two-preview','revision-three-preview'): data['preview'] = data['current']
            if state == 'revision-two-read': data['ack'] = 2
            if state == 'revision-three-read': data['ack'] = 3
            if state == 'withdrawn':
                data['withdrawn'] = True
                data['preview'] = None
    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('revision-one-read / revision-two-arrives', solve('revision-one-read', [('revision-two-arrives', N)], N), 'revision-two-unread')
check('revision-two-unread / open-revision', solve('revision-two-unread', [('open-revision', N)], N), 'revision-two-preview')
check('revision-two-preview / ack-revision', solve('revision-two-preview', [('ack-revision', N)], N), 'revision-two-read')
check('revision-two-preview / revision-three-arrives', solve('revision-two-preview', [('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('revision-three-pending-review / accept-update', solve('revision-three-pending-review', [('accept-update', N)], N), 'revision-three-preview')
check('revision-three-preview / ack-revision', solve('revision-three-preview', [('ack-revision', N)], N), 'revision-three-read')
check('revision-three-read / late-revision-two', solve('revision-three-read', [('late-revision-two', N)], N), 'revision-three-read')
check('revision-three-pending-review / close-preview', solve('revision-three-pending-review', [('close-preview', N)], N), 'revision-three-unread')
check('revision-three-unread / open-revision', solve('revision-three-unread', [('open-revision', N)], N), 'revision-three-preview')
check('revision-two-unread / revision-withdrawn', solve('revision-two-unread', [('revision-withdrawn', N)], N), 'withdrawn')
check('older notification incarnation', solve('revision-one-read', [('revision-two-arrives', N - 1)], N), 'revision-one-read')
check('future notification incarnation', solve('revision-one-read', [('revision-two-arrives', N + 1)], N), 'revision-one-read')
check('unknown event is inert', solve('revision-one-read', [('unknown-event', N)], N), 'revision-one-read')
check('empty delivery batch', solve('revision-one-read', [], N), 'revision-one-read')
check('N stale deliveries before current delivery', solve('revision-one-read', [('revision-two-arrives', N - 1)] * N + [('revision-two-arrives', N)], N), 'revision-two-unread')
check('trace revision-two-arrives then open-revision', solve('revision-one-read', [('revision-two-arrives', N), ('open-revision', N)], N), 'revision-two-preview')
check('trace revision-two-arrives then revision-withdrawn', solve('revision-one-read', [('revision-two-arrives', N), ('revision-withdrawn', N)], N), 'withdrawn')
check('trace open-revision then ack-revision', solve('revision-two-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-two-read')
check('trace open-revision then revision-three-arrives', solve('revision-two-unread', [('open-revision', N), ('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('trace revision-three-arrives then accept-update', solve('revision-two-preview', [('revision-three-arrives', N), ('accept-update', N)], N), 'revision-three-preview')
check('trace revision-three-arrives then close-preview', solve('revision-two-preview', [('revision-three-arrives', N), ('close-preview', N)], N), 'revision-three-unread')
check('trace accept-update then ack-revision', solve('revision-three-pending-review', [('accept-update', N), ('ack-revision', N)], N), 'revision-three-read')
check('trace ack-revision then late-revision-two', solve('revision-three-preview', [('ack-revision', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace late-revision-two then late-revision-two', solve('revision-three-read', [('late-revision-two', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace close-preview then open-revision', solve('revision-three-pending-review', [('close-preview', N), ('open-revision', N)], N), 'revision-three-preview')
check('trace open-revision then ack-revision', solve('revision-three-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-three-read')
check('domain state regression 1: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 1})], N, {}, 'ack'), {'phase': 'revision-two-preview', 'value': 1})
check('domain state regression 2: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 2})], N, {}, 'ack'), {'phase': 'revision-two-read', 'value': 2})
check('domain state regression 3: preview', solve('revision-two-preview', [('revision-three-arrives', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'revision-three-pending-review', 'value': 2})
check('domain state regression 4: preview', solve('revision-three-pending-review', [('accept-update', N, {})], N, {'current': 3, 'preview': 2}, 'preview'), {'phase': 'revision-three-preview', 'value': 3})
check('domain state regression 5: current', solve('revision-three-read', [('late-revision-two', N, {})], N, {'current': 3, 'ack': 3}, 'current'), {'phase': 'revision-three-read', 'value': 3})
check('domain state regression 6: preview', solve('revision-two-unread', [('revision-withdrawn', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'withdrawn', 'value': None})
check('domain state regression 7: ack', solve('revision-two-preview', [('revision-three-arrives', N, {}), ('accept-update', N, {}), ('ack-revision', N, {'revision': 2}), ('ack-revision', N, {'revision': 3})], N, {}, 'ack'), {'phase': 'revision-three-read', 'value': 3})
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 accept-update event leaves a notification in revision-three-read instead of revision-three-preview.

Notification content revision review is a bounded visual-notification workflow with mutable policy state {'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False}. Its default transition relation is {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}; 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 = {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-two-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}
    data = json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False})) if payload is None else {**json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': 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 == 'ack-revision' and arg.get('revision',data['current']) != data['current']: event = 'unknown-event'
            if event == 'revision-three-arrives': data['current'] = 3
            state = table.get((state, event), state)
            if state in ('revision-two-preview','revision-three-preview'): data['preview'] = data['current']
            if state == 'revision-two-read': data['ack'] = 2
            if state == 'revision-three-read': data['ack'] = 3
            if state == 'withdrawn':
                data['withdrawn'] = True
                data['preview'] = None
    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('revision-one-read / revision-two-arrives', solve('revision-one-read', [('revision-two-arrives', N)], N), 'revision-two-unread')
check('revision-two-unread / open-revision', solve('revision-two-unread', [('open-revision', N)], N), 'revision-two-preview')
check('revision-two-preview / ack-revision', solve('revision-two-preview', [('ack-revision', N)], N), 'revision-two-read')
check('revision-two-preview / revision-three-arrives', solve('revision-two-preview', [('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('revision-three-pending-review / accept-update', solve('revision-three-pending-review', [('accept-update', N)], N), 'revision-three-preview')
check('revision-three-preview / ack-revision', solve('revision-three-preview', [('ack-revision', N)], N), 'revision-three-read')
check('revision-three-read / late-revision-two', solve('revision-three-read', [('late-revision-two', N)], N), 'revision-three-read')
check('revision-three-pending-review / close-preview', solve('revision-three-pending-review', [('close-preview', N)], N), 'revision-three-unread')
check('revision-three-unread / open-revision', solve('revision-three-unread', [('open-revision', N)], N), 'revision-three-preview')
check('revision-two-unread / revision-withdrawn', solve('revision-two-unread', [('revision-withdrawn', N)], N), 'withdrawn')
check('older notification incarnation', solve('revision-one-read', [('revision-two-arrives', N - 1)], N), 'revision-one-read')
check('future notification incarnation', solve('revision-one-read', [('revision-two-arrives', N + 1)], N), 'revision-one-read')
check('unknown event is inert', solve('revision-one-read', [('unknown-event', N)], N), 'revision-one-read')
check('empty delivery batch', solve('revision-one-read', [], N), 'revision-one-read')
check('N stale deliveries before current delivery', solve('revision-one-read', [('revision-two-arrives', N - 1)] * N + [('revision-two-arrives', N)], N), 'revision-two-unread')
check('trace revision-two-arrives then open-revision', solve('revision-one-read', [('revision-two-arrives', N), ('open-revision', N)], N), 'revision-two-preview')
check('trace revision-two-arrives then revision-withdrawn', solve('revision-one-read', [('revision-two-arrives', N), ('revision-withdrawn', N)], N), 'withdrawn')
check('trace open-revision then ack-revision', solve('revision-two-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-two-read')
check('trace open-revision then revision-three-arrives', solve('revision-two-unread', [('open-revision', N), ('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('trace revision-three-arrives then accept-update', solve('revision-two-preview', [('revision-three-arrives', N), ('accept-update', N)], N), 'revision-three-preview')
check('trace revision-three-arrives then close-preview', solve('revision-two-preview', [('revision-three-arrives', N), ('close-preview', N)], N), 'revision-three-unread')
check('trace accept-update then ack-revision', solve('revision-three-pending-review', [('accept-update', N), ('ack-revision', N)], N), 'revision-three-read')
check('trace ack-revision then late-revision-two', solve('revision-three-preview', [('ack-revision', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace late-revision-two then late-revision-two', solve('revision-three-read', [('late-revision-two', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace close-preview then open-revision', solve('revision-three-pending-review', [('close-preview', N), ('open-revision', N)], N), 'revision-three-preview')
check('trace open-revision then ack-revision', solve('revision-three-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-three-read')
check('domain state regression 1: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 1})], N, {}, 'ack'), {'phase': 'revision-two-preview', 'value': 1})
check('domain state regression 2: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 2})], N, {}, 'ack'), {'phase': 'revision-two-read', 'value': 2})
check('domain state regression 3: preview', solve('revision-two-preview', [('revision-three-arrives', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'revision-three-pending-review', 'value': 2})
check('domain state regression 4: preview', solve('revision-three-pending-review', [('accept-update', N, {})], N, {'current': 3, 'preview': 2}, 'preview'), {'phase': 'revision-three-preview', 'value': 3})
check('domain state regression 5: current', solve('revision-three-read', [('late-revision-two', N, {})], N, {'current': 3, 'ack': 3}, 'current'), {'phase': 'revision-three-read', 'value': 3})
check('domain state regression 6: preview', solve('revision-two-unread', [('revision-withdrawn', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'withdrawn', 'value': None})
check('domain state regression 7: ack', solve('revision-two-preview', [('revision-three-arrives', N, {}), ('accept-update', N, {}), ('ack-revision', N, {'revision': 2}), ('ack-revision', N, {'revision': 3})], N, {}, 'ack'), {'phase': 'revision-three-read', 'value': 3})
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 = {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-pending-review', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}
    data = json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False})) if payload is None else {**json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': 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 == 'ack-revision' and arg.get('revision',data['current']) != data['current']: event = 'unknown-event'
            if event == 'revision-three-arrives': data['current'] = 3
            state = table.get((state, event), state)
            if state in ('revision-two-preview','revision-three-preview'): data['preview'] = data['current']
            if state == 'revision-two-read': data['ack'] = 2
            if state == 'revision-three-read': data['ack'] = 3
            if state == 'withdrawn':
                data['withdrawn'] = True
                data['preview'] = None
    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('revision-one-read / revision-two-arrives', solve('revision-one-read', [('revision-two-arrives', N)], N), 'revision-two-unread')
check('revision-two-unread / open-revision', solve('revision-two-unread', [('open-revision', N)], N), 'revision-two-preview')
check('revision-two-preview / ack-revision', solve('revision-two-preview', [('ack-revision', N)], N), 'revision-two-read')
check('revision-two-preview / revision-three-arrives', solve('revision-two-preview', [('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('revision-three-pending-review / accept-update', solve('revision-three-pending-review', [('accept-update', N)], N), 'revision-three-preview')
check('revision-three-preview / ack-revision', solve('revision-three-preview', [('ack-revision', N)], N), 'revision-three-read')
check('revision-three-read / late-revision-two', solve('revision-three-read', [('late-revision-two', N)], N), 'revision-three-read')
check('revision-three-pending-review / close-preview', solve('revision-three-pending-review', [('close-preview', N)], N), 'revision-three-unread')
check('revision-three-unread / open-revision', solve('revision-three-unread', [('open-revision', N)], N), 'revision-three-preview')
check('revision-two-unread / revision-withdrawn', solve('revision-two-unread', [('revision-withdrawn', N)], N), 'withdrawn')
check('older notification incarnation', solve('revision-one-read', [('revision-two-arrives', N - 1)], N), 'revision-one-read')
check('future notification incarnation', solve('revision-one-read', [('revision-two-arrives', N + 1)], N), 'revision-one-read')
check('unknown event is inert', solve('revision-one-read', [('unknown-event', N)], N), 'revision-one-read')
check('empty delivery batch', solve('revision-one-read', [], N), 'revision-one-read')
check('N stale deliveries before current delivery', solve('revision-one-read', [('revision-two-arrives', N - 1)] * N + [('revision-two-arrives', N)], N), 'revision-two-unread')
check('trace revision-two-arrives then open-revision', solve('revision-one-read', [('revision-two-arrives', N), ('open-revision', N)], N), 'revision-two-preview')
check('trace revision-two-arrives then revision-withdrawn', solve('revision-one-read', [('revision-two-arrives', N), ('revision-withdrawn', N)], N), 'withdrawn')
check('trace open-revision then ack-revision', solve('revision-two-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-two-read')
check('trace open-revision then revision-three-arrives', solve('revision-two-unread', [('open-revision', N), ('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('trace revision-three-arrives then accept-update', solve('revision-two-preview', [('revision-three-arrives', N), ('accept-update', N)], N), 'revision-three-preview')
check('trace revision-three-arrives then close-preview', solve('revision-two-preview', [('revision-three-arrives', N), ('close-preview', N)], N), 'revision-three-unread')
check('trace accept-update then ack-revision', solve('revision-three-pending-review', [('accept-update', N), ('ack-revision', N)], N), 'revision-three-read')
check('trace ack-revision then late-revision-two', solve('revision-three-preview', [('ack-revision', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace late-revision-two then late-revision-two', solve('revision-three-read', [('late-revision-two', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace close-preview then open-revision', solve('revision-three-pending-review', [('close-preview', N), ('open-revision', N)], N), 'revision-three-preview')
check('trace open-revision then ack-revision', solve('revision-three-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-three-read')
check('domain state regression 1: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 1})], N, {}, 'ack'), {'phase': 'revision-two-preview', 'value': 1})
check('domain state regression 2: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 2})], N, {}, 'ack'), {'phase': 'revision-two-read', 'value': 2})
check('domain state regression 3: preview', solve('revision-two-preview', [('revision-three-arrives', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'revision-three-pending-review', 'value': 2})
check('domain state regression 4: preview', solve('revision-three-pending-review', [('accept-update', N, {})], N, {'current': 3, 'preview': 2}, 'preview'), {'phase': 'revision-three-preview', 'value': 3})
check('domain state regression 5: current', solve('revision-three-read', [('late-revision-two', N, {})], N, {'current': 3, 'ack': 3}, 'current'), {'phase': 'revision-three-read', 'value': 3})
check('domain state regression 6: preview', solve('revision-two-unread', [('revision-withdrawn', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'withdrawn', 'value': None})
check('domain state regression 7: ack', solve('revision-two-preview', [('revision-three-arrives', N, {}), ('accept-update', N, {}), ('ack-revision', N, {'revision': 2}), ('ack-revision', N, {'revision': 3})], N, {}, 'ack'), {'phase': 'revision-three-read', 'value': 3})
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 ack-revision event leaves a notification in revision-two-read instead of revision-three-read.

Notification content revision review is a bounded visual-notification workflow with mutable policy state {'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False}. Its default transition relation is {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}; 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 = {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-two-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}
    data = json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False})) if payload is None else {**json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': 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 == 'ack-revision' and arg.get('revision',data['current']) != data['current']: event = 'unknown-event'
            if event == 'revision-three-arrives': data['current'] = 3
            state = table.get((state, event), state)
            if state in ('revision-two-preview','revision-three-preview'): data['preview'] = data['current']
            if state == 'revision-two-read': data['ack'] = 2
            if state == 'revision-three-read': data['ack'] = 3
            if state == 'withdrawn':
                data['withdrawn'] = True
                data['preview'] = None
    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('revision-one-read / revision-two-arrives', solve('revision-one-read', [('revision-two-arrives', N)], N), 'revision-two-unread')
check('revision-two-unread / open-revision', solve('revision-two-unread', [('open-revision', N)], N), 'revision-two-preview')
check('revision-two-preview / ack-revision', solve('revision-two-preview', [('ack-revision', N)], N), 'revision-two-read')
check('revision-two-preview / revision-three-arrives', solve('revision-two-preview', [('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('revision-three-pending-review / accept-update', solve('revision-three-pending-review', [('accept-update', N)], N), 'revision-three-preview')
check('revision-three-preview / ack-revision', solve('revision-three-preview', [('ack-revision', N)], N), 'revision-three-read')
check('revision-three-read / late-revision-two', solve('revision-three-read', [('late-revision-two', N)], N), 'revision-three-read')
check('revision-three-pending-review / close-preview', solve('revision-three-pending-review', [('close-preview', N)], N), 'revision-three-unread')
check('revision-three-unread / open-revision', solve('revision-three-unread', [('open-revision', N)], N), 'revision-three-preview')
check('revision-two-unread / revision-withdrawn', solve('revision-two-unread', [('revision-withdrawn', N)], N), 'withdrawn')
check('older notification incarnation', solve('revision-one-read', [('revision-two-arrives', N - 1)], N), 'revision-one-read')
check('future notification incarnation', solve('revision-one-read', [('revision-two-arrives', N + 1)], N), 'revision-one-read')
check('unknown event is inert', solve('revision-one-read', [('unknown-event', N)], N), 'revision-one-read')
check('empty delivery batch', solve('revision-one-read', [], N), 'revision-one-read')
check('N stale deliveries before current delivery', solve('revision-one-read', [('revision-two-arrives', N - 1)] * N + [('revision-two-arrives', N)], N), 'revision-two-unread')
check('trace revision-two-arrives then open-revision', solve('revision-one-read', [('revision-two-arrives', N), ('open-revision', N)], N), 'revision-two-preview')
check('trace revision-two-arrives then revision-withdrawn', solve('revision-one-read', [('revision-two-arrives', N), ('revision-withdrawn', N)], N), 'withdrawn')
check('trace open-revision then ack-revision', solve('revision-two-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-two-read')
check('trace open-revision then revision-three-arrives', solve('revision-two-unread', [('open-revision', N), ('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('trace revision-three-arrives then accept-update', solve('revision-two-preview', [('revision-three-arrives', N), ('accept-update', N)], N), 'revision-three-preview')
check('trace revision-three-arrives then close-preview', solve('revision-two-preview', [('revision-three-arrives', N), ('close-preview', N)], N), 'revision-three-unread')
check('trace accept-update then ack-revision', solve('revision-three-pending-review', [('accept-update', N), ('ack-revision', N)], N), 'revision-three-read')
check('trace ack-revision then late-revision-two', solve('revision-three-preview', [('ack-revision', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace late-revision-two then late-revision-two', solve('revision-three-read', [('late-revision-two', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace close-preview then open-revision', solve('revision-three-pending-review', [('close-preview', N), ('open-revision', N)], N), 'revision-three-preview')
check('trace open-revision then ack-revision', solve('revision-three-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-three-read')
check('domain state regression 1: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 1})], N, {}, 'ack'), {'phase': 'revision-two-preview', 'value': 1})
check('domain state regression 2: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 2})], N, {}, 'ack'), {'phase': 'revision-two-read', 'value': 2})
check('domain state regression 3: preview', solve('revision-two-preview', [('revision-three-arrives', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'revision-three-pending-review', 'value': 2})
check('domain state regression 4: preview', solve('revision-three-pending-review', [('accept-update', N, {})], N, {'current': 3, 'preview': 2}, 'preview'), {'phase': 'revision-three-preview', 'value': 3})
check('domain state regression 5: current', solve('revision-three-read', [('late-revision-two', N, {})], N, {'current': 3, 'ack': 3}, 'current'), {'phase': 'revision-three-read', 'value': 3})
check('domain state regression 6: preview', solve('revision-two-unread', [('revision-withdrawn', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'withdrawn', 'value': None})
check('domain state regression 7: ack', solve('revision-two-preview', [('revision-three-arrives', N, {}), ('accept-update', N, {}), ('ack-revision', N, {'revision': 2}), ('ack-revision', N, {'revision': 3})], N, {}, 'ack'), {'phase': 'revision-three-read', 'value': 3})
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 = {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-two-unread', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}
    data = json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False})) if payload is None else {**json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': 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 == 'ack-revision' and arg.get('revision',data['current']) != data['current']: event = 'unknown-event'
            if event == 'revision-three-arrives': data['current'] = 3
            state = table.get((state, event), state)
            if state in ('revision-two-preview','revision-three-preview'): data['preview'] = data['current']
            if state == 'revision-two-read': data['ack'] = 2
            if state == 'revision-three-read': data['ack'] = 3
            if state == 'withdrawn':
                data['withdrawn'] = True
                data['preview'] = None
    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('revision-one-read / revision-two-arrives', solve('revision-one-read', [('revision-two-arrives', N)], N), 'revision-two-unread')
check('revision-two-unread / open-revision', solve('revision-two-unread', [('open-revision', N)], N), 'revision-two-preview')
check('revision-two-preview / ack-revision', solve('revision-two-preview', [('ack-revision', N)], N), 'revision-two-read')
check('revision-two-preview / revision-three-arrives', solve('revision-two-preview', [('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('revision-three-pending-review / accept-update', solve('revision-three-pending-review', [('accept-update', N)], N), 'revision-three-preview')
check('revision-three-preview / ack-revision', solve('revision-three-preview', [('ack-revision', N)], N), 'revision-three-read')
check('revision-three-read / late-revision-two', solve('revision-three-read', [('late-revision-two', N)], N), 'revision-three-read')
check('revision-three-pending-review / close-preview', solve('revision-three-pending-review', [('close-preview', N)], N), 'revision-three-unread')
check('revision-three-unread / open-revision', solve('revision-three-unread', [('open-revision', N)], N), 'revision-three-preview')
check('revision-two-unread / revision-withdrawn', solve('revision-two-unread', [('revision-withdrawn', N)], N), 'withdrawn')
check('older notification incarnation', solve('revision-one-read', [('revision-two-arrives', N - 1)], N), 'revision-one-read')
check('future notification incarnation', solve('revision-one-read', [('revision-two-arrives', N + 1)], N), 'revision-one-read')
check('unknown event is inert', solve('revision-one-read', [('unknown-event', N)], N), 'revision-one-read')
check('empty delivery batch', solve('revision-one-read', [], N), 'revision-one-read')
check('N stale deliveries before current delivery', solve('revision-one-read', [('revision-two-arrives', N - 1)] * N + [('revision-two-arrives', N)], N), 'revision-two-unread')
check('trace revision-two-arrives then open-revision', solve('revision-one-read', [('revision-two-arrives', N), ('open-revision', N)], N), 'revision-two-preview')
check('trace revision-two-arrives then revision-withdrawn', solve('revision-one-read', [('revision-two-arrives', N), ('revision-withdrawn', N)], N), 'withdrawn')
check('trace open-revision then ack-revision', solve('revision-two-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-two-read')
check('trace open-revision then revision-three-arrives', solve('revision-two-unread', [('open-revision', N), ('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('trace revision-three-arrives then accept-update', solve('revision-two-preview', [('revision-three-arrives', N), ('accept-update', N)], N), 'revision-three-preview')
check('trace revision-three-arrives then close-preview', solve('revision-two-preview', [('revision-three-arrives', N), ('close-preview', N)], N), 'revision-three-unread')
check('trace accept-update then ack-revision', solve('revision-three-pending-review', [('accept-update', N), ('ack-revision', N)], N), 'revision-three-read')
check('trace ack-revision then late-revision-two', solve('revision-three-preview', [('ack-revision', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace late-revision-two then late-revision-two', solve('revision-three-read', [('late-revision-two', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace close-preview then open-revision', solve('revision-three-pending-review', [('close-preview', N), ('open-revision', N)], N), 'revision-three-preview')
check('trace open-revision then ack-revision', solve('revision-three-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-three-read')
check('domain state regression 1: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 1})], N, {}, 'ack'), {'phase': 'revision-two-preview', 'value': 1})
check('domain state regression 2: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 2})], N, {}, 'ack'), {'phase': 'revision-two-read', 'value': 2})
check('domain state regression 3: preview', solve('revision-two-preview', [('revision-three-arrives', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'revision-three-pending-review', 'value': 2})
check('domain state regression 4: preview', solve('revision-three-pending-review', [('accept-update', N, {})], N, {'current': 3, 'preview': 2}, 'preview'), {'phase': 'revision-three-preview', 'value': 3})
check('domain state regression 5: current', solve('revision-three-read', [('late-revision-two', N, {})], N, {'current': 3, 'ack': 3}, 'current'), {'phase': 'revision-three-read', 'value': 3})
check('domain state regression 6: preview', solve('revision-two-unread', [('revision-withdrawn', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'withdrawn', 'value': None})
check('domain state regression 7: ack', solve('revision-two-preview', [('revision-three-arrives', N, {}), ('accept-update', N, {}), ('ack-revision', N, {'revision': 2}), ('ack-revision', N, {'revision': 3})], N, {}, 'ack'), {'phase': 'revision-three-read', 'value': 3})
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 late-revision-two event leaves a notification in revision-two-read instead of revision-three-read.

Notification content revision review is a bounded visual-notification workflow with mutable policy state {'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False}. Its default transition relation is {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}; 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 = {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-read', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}
    data = json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False})) if payload is None else {**json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': 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 == 'ack-revision' and arg.get('revision',data['current']) != data['current']: event = 'unknown-event'
            if event == 'revision-three-arrives': data['current'] = 3
            state = table.get((state, event), state)
            if state in ('revision-two-preview','revision-three-preview'): data['preview'] = data['current']
            if state == 'revision-two-read': data['ack'] = 2
            if state == 'revision-three-read': data['ack'] = 3
            if state == 'withdrawn':
                data['withdrawn'] = True
                data['preview'] = None
    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('revision-one-read / revision-two-arrives', solve('revision-one-read', [('revision-two-arrives', N)], N), 'revision-two-unread')
check('revision-two-unread / open-revision', solve('revision-two-unread', [('open-revision', N)], N), 'revision-two-preview')
check('revision-two-preview / ack-revision', solve('revision-two-preview', [('ack-revision', N)], N), 'revision-two-read')
check('revision-two-preview / revision-three-arrives', solve('revision-two-preview', [('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('revision-three-pending-review / accept-update', solve('revision-three-pending-review', [('accept-update', N)], N), 'revision-three-preview')
check('revision-three-preview / ack-revision', solve('revision-three-preview', [('ack-revision', N)], N), 'revision-three-read')
check('revision-three-read / late-revision-two', solve('revision-three-read', [('late-revision-two', N)], N), 'revision-three-read')
check('revision-three-pending-review / close-preview', solve('revision-three-pending-review', [('close-preview', N)], N), 'revision-three-unread')
check('revision-three-unread / open-revision', solve('revision-three-unread', [('open-revision', N)], N), 'revision-three-preview')
check('revision-two-unread / revision-withdrawn', solve('revision-two-unread', [('revision-withdrawn', N)], N), 'withdrawn')
check('older notification incarnation', solve('revision-one-read', [('revision-two-arrives', N - 1)], N), 'revision-one-read')
check('future notification incarnation', solve('revision-one-read', [('revision-two-arrives', N + 1)], N), 'revision-one-read')
check('unknown event is inert', solve('revision-one-read', [('unknown-event', N)], N), 'revision-one-read')
check('empty delivery batch', solve('revision-one-read', [], N), 'revision-one-read')
check('N stale deliveries before current delivery', solve('revision-one-read', [('revision-two-arrives', N - 1)] * N + [('revision-two-arrives', N)], N), 'revision-two-unread')
check('trace revision-two-arrives then open-revision', solve('revision-one-read', [('revision-two-arrives', N), ('open-revision', N)], N), 'revision-two-preview')
check('trace revision-two-arrives then revision-withdrawn', solve('revision-one-read', [('revision-two-arrives', N), ('revision-withdrawn', N)], N), 'withdrawn')
check('trace open-revision then ack-revision', solve('revision-two-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-two-read')
check('trace open-revision then revision-three-arrives', solve('revision-two-unread', [('open-revision', N), ('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('trace revision-three-arrives then accept-update', solve('revision-two-preview', [('revision-three-arrives', N), ('accept-update', N)], N), 'revision-three-preview')
check('trace revision-three-arrives then close-preview', solve('revision-two-preview', [('revision-three-arrives', N), ('close-preview', N)], N), 'revision-three-unread')
check('trace accept-update then ack-revision', solve('revision-three-pending-review', [('accept-update', N), ('ack-revision', N)], N), 'revision-three-read')
check('trace ack-revision then late-revision-two', solve('revision-three-preview', [('ack-revision', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace late-revision-two then late-revision-two', solve('revision-three-read', [('late-revision-two', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace close-preview then open-revision', solve('revision-three-pending-review', [('close-preview', N), ('open-revision', N)], N), 'revision-three-preview')
check('trace open-revision then ack-revision', solve('revision-three-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-three-read')
check('domain state regression 1: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 1})], N, {}, 'ack'), {'phase': 'revision-two-preview', 'value': 1})
check('domain state regression 2: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 2})], N, {}, 'ack'), {'phase': 'revision-two-read', 'value': 2})
check('domain state regression 3: preview', solve('revision-two-preview', [('revision-three-arrives', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'revision-three-pending-review', 'value': 2})
check('domain state regression 4: preview', solve('revision-three-pending-review', [('accept-update', N, {})], N, {'current': 3, 'preview': 2}, 'preview'), {'phase': 'revision-three-preview', 'value': 3})
check('domain state regression 5: current', solve('revision-three-read', [('late-revision-two', N, {})], N, {'current': 3, 'ack': 3}, 'current'), {'phase': 'revision-three-read', 'value': 3})
check('domain state regression 6: preview', solve('revision-two-unread', [('revision-withdrawn', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'withdrawn', 'value': None})
check('domain state regression 7: ack', solve('revision-two-preview', [('revision-three-arrives', N, {}), ('accept-update', N, {}), ('ack-revision', N, {'revision': 2}), ('ack-revision', N, {'revision': 3})], N, {}, 'ack'), {'phase': 'revision-three-read', 'value': 3})
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 = {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-two-read', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}
    data = json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False})) if payload is None else {**json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': 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 == 'ack-revision' and arg.get('revision',data['current']) != data['current']: event = 'unknown-event'
            if event == 'revision-three-arrives': data['current'] = 3
            state = table.get((state, event), state)
            if state in ('revision-two-preview','revision-three-preview'): data['preview'] = data['current']
            if state == 'revision-two-read': data['ack'] = 2
            if state == 'revision-three-read': data['ack'] = 3
            if state == 'withdrawn':
                data['withdrawn'] = True
                data['preview'] = None
    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('revision-one-read / revision-two-arrives', solve('revision-one-read', [('revision-two-arrives', N)], N), 'revision-two-unread')
check('revision-two-unread / open-revision', solve('revision-two-unread', [('open-revision', N)], N), 'revision-two-preview')
check('revision-two-preview / ack-revision', solve('revision-two-preview', [('ack-revision', N)], N), 'revision-two-read')
check('revision-two-preview / revision-three-arrives', solve('revision-two-preview', [('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('revision-three-pending-review / accept-update', solve('revision-three-pending-review', [('accept-update', N)], N), 'revision-three-preview')
check('revision-three-preview / ack-revision', solve('revision-three-preview', [('ack-revision', N)], N), 'revision-three-read')
check('revision-three-read / late-revision-two', solve('revision-three-read', [('late-revision-two', N)], N), 'revision-three-read')
check('revision-three-pending-review / close-preview', solve('revision-three-pending-review', [('close-preview', N)], N), 'revision-three-unread')
check('revision-three-unread / open-revision', solve('revision-three-unread', [('open-revision', N)], N), 'revision-three-preview')
check('revision-two-unread / revision-withdrawn', solve('revision-two-unread', [('revision-withdrawn', N)], N), 'withdrawn')
check('older notification incarnation', solve('revision-one-read', [('revision-two-arrives', N - 1)], N), 'revision-one-read')
check('future notification incarnation', solve('revision-one-read', [('revision-two-arrives', N + 1)], N), 'revision-one-read')
check('unknown event is inert', solve('revision-one-read', [('unknown-event', N)], N), 'revision-one-read')
check('empty delivery batch', solve('revision-one-read', [], N), 'revision-one-read')
check('N stale deliveries before current delivery', solve('revision-one-read', [('revision-two-arrives', N - 1)] * N + [('revision-two-arrives', N)], N), 'revision-two-unread')
check('trace revision-two-arrives then open-revision', solve('revision-one-read', [('revision-two-arrives', N), ('open-revision', N)], N), 'revision-two-preview')
check('trace revision-two-arrives then revision-withdrawn', solve('revision-one-read', [('revision-two-arrives', N), ('revision-withdrawn', N)], N), 'withdrawn')
check('trace open-revision then ack-revision', solve('revision-two-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-two-read')
check('trace open-revision then revision-three-arrives', solve('revision-two-unread', [('open-revision', N), ('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('trace revision-three-arrives then accept-update', solve('revision-two-preview', [('revision-three-arrives', N), ('accept-update', N)], N), 'revision-three-preview')
check('trace revision-three-arrives then close-preview', solve('revision-two-preview', [('revision-three-arrives', N), ('close-preview', N)], N), 'revision-three-unread')
check('trace accept-update then ack-revision', solve('revision-three-pending-review', [('accept-update', N), ('ack-revision', N)], N), 'revision-three-read')
check('trace ack-revision then late-revision-two', solve('revision-three-preview', [('ack-revision', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace late-revision-two then late-revision-two', solve('revision-three-read', [('late-revision-two', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace close-preview then open-revision', solve('revision-three-pending-review', [('close-preview', N), ('open-revision', N)], N), 'revision-three-preview')
check('trace open-revision then ack-revision', solve('revision-three-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-three-read')
check('domain state regression 1: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 1})], N, {}, 'ack'), {'phase': 'revision-two-preview', 'value': 1})
check('domain state regression 2: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 2})], N, {}, 'ack'), {'phase': 'revision-two-read', 'value': 2})
check('domain state regression 3: preview', solve('revision-two-preview', [('revision-three-arrives', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'revision-three-pending-review', 'value': 2})
check('domain state regression 4: preview', solve('revision-three-pending-review', [('accept-update', N, {})], N, {'current': 3, 'preview': 2}, 'preview'), {'phase': 'revision-three-preview', 'value': 3})
check('domain state regression 5: current', solve('revision-three-read', [('late-revision-two', N, {})], N, {'current': 3, 'ack': 3}, 'current'), {'phase': 'revision-three-read', 'value': 3})
check('domain state regression 6: preview', solve('revision-two-unread', [('revision-withdrawn', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'withdrawn', 'value': None})
check('domain state regression 7: ack', solve('revision-two-preview', [('revision-three-arrives', N, {}), ('accept-update', N, {}), ('ack-revision', N, {'revision': 2}), ('ack-revision', N, {'revision': 3})], N, {}, 'ack'), {'phase': 'revision-three-read', 'value': 3})
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 close-preview event leaves a notification in revision-three-read instead of revision-three-unread.

Notification content revision review is a bounded visual-notification workflow with mutable policy state {'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False}. Its default transition relation is {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}; 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 = {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-two-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}
    data = json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False})) if payload is None else {**json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': 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 == 'ack-revision' and arg.get('revision',data['current']) != data['current']: event = 'unknown-event'
            if event == 'revision-three-arrives': data['current'] = 3
            state = table.get((state, event), state)
            if state in ('revision-two-preview','revision-three-preview'): data['preview'] = data['current']
            if state == 'revision-two-read': data['ack'] = 2
            if state == 'revision-three-read': data['ack'] = 3
            if state == 'withdrawn':
                data['withdrawn'] = True
                data['preview'] = None
    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('revision-one-read / revision-two-arrives', solve('revision-one-read', [('revision-two-arrives', N)], N), 'revision-two-unread')
check('revision-two-unread / open-revision', solve('revision-two-unread', [('open-revision', N)], N), 'revision-two-preview')
check('revision-two-preview / ack-revision', solve('revision-two-preview', [('ack-revision', N)], N), 'revision-two-read')
check('revision-two-preview / revision-three-arrives', solve('revision-two-preview', [('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('revision-three-pending-review / accept-update', solve('revision-three-pending-review', [('accept-update', N)], N), 'revision-three-preview')
check('revision-three-preview / ack-revision', solve('revision-three-preview', [('ack-revision', N)], N), 'revision-three-read')
check('revision-three-read / late-revision-two', solve('revision-three-read', [('late-revision-two', N)], N), 'revision-three-read')
check('revision-three-pending-review / close-preview', solve('revision-three-pending-review', [('close-preview', N)], N), 'revision-three-unread')
check('revision-three-unread / open-revision', solve('revision-three-unread', [('open-revision', N)], N), 'revision-three-preview')
check('revision-two-unread / revision-withdrawn', solve('revision-two-unread', [('revision-withdrawn', N)], N), 'withdrawn')
check('older notification incarnation', solve('revision-one-read', [('revision-two-arrives', N - 1)], N), 'revision-one-read')
check('future notification incarnation', solve('revision-one-read', [('revision-two-arrives', N + 1)], N), 'revision-one-read')
check('unknown event is inert', solve('revision-one-read', [('unknown-event', N)], N), 'revision-one-read')
check('empty delivery batch', solve('revision-one-read', [], N), 'revision-one-read')
check('N stale deliveries before current delivery', solve('revision-one-read', [('revision-two-arrives', N - 1)] * N + [('revision-two-arrives', N)], N), 'revision-two-unread')
check('trace revision-two-arrives then open-revision', solve('revision-one-read', [('revision-two-arrives', N), ('open-revision', N)], N), 'revision-two-preview')
check('trace revision-two-arrives then revision-withdrawn', solve('revision-one-read', [('revision-two-arrives', N), ('revision-withdrawn', N)], N), 'withdrawn')
check('trace open-revision then ack-revision', solve('revision-two-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-two-read')
check('trace open-revision then revision-three-arrives', solve('revision-two-unread', [('open-revision', N), ('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('trace revision-three-arrives then accept-update', solve('revision-two-preview', [('revision-three-arrives', N), ('accept-update', N)], N), 'revision-three-preview')
check('trace revision-three-arrives then close-preview', solve('revision-two-preview', [('revision-three-arrives', N), ('close-preview', N)], N), 'revision-three-unread')
check('trace accept-update then ack-revision', solve('revision-three-pending-review', [('accept-update', N), ('ack-revision', N)], N), 'revision-three-read')
check('trace ack-revision then late-revision-two', solve('revision-three-preview', [('ack-revision', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace late-revision-two then late-revision-two', solve('revision-three-read', [('late-revision-two', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace close-preview then open-revision', solve('revision-three-pending-review', [('close-preview', N), ('open-revision', N)], N), 'revision-three-preview')
check('trace open-revision then ack-revision', solve('revision-three-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-three-read')
check('domain state regression 1: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 1})], N, {}, 'ack'), {'phase': 'revision-two-preview', 'value': 1})
check('domain state regression 2: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 2})], N, {}, 'ack'), {'phase': 'revision-two-read', 'value': 2})
check('domain state regression 3: preview', solve('revision-two-preview', [('revision-three-arrives', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'revision-three-pending-review', 'value': 2})
check('domain state regression 4: preview', solve('revision-three-pending-review', [('accept-update', N, {})], N, {'current': 3, 'preview': 2}, 'preview'), {'phase': 'revision-three-preview', 'value': 3})
check('domain state regression 5: current', solve('revision-three-read', [('late-revision-two', N, {})], N, {'current': 3, 'ack': 3}, 'current'), {'phase': 'revision-three-read', 'value': 3})
check('domain state regression 6: preview', solve('revision-two-unread', [('revision-withdrawn', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'withdrawn', 'value': None})
check('domain state regression 7: ack', solve('revision-two-preview', [('revision-three-arrives', N, {}), ('accept-update', N, {}), ('ack-revision', N, {'revision': 2}), ('ack-revision', N, {'revision': 3})], N, {}, 'ack'), {'phase': 'revision-three-read', 'value': 3})
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 = {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-read', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}
    data = json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False})) if payload is None else {**json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': 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 == 'ack-revision' and arg.get('revision',data['current']) != data['current']: event = 'unknown-event'
            if event == 'revision-three-arrives': data['current'] = 3
            state = table.get((state, event), state)
            if state in ('revision-two-preview','revision-three-preview'): data['preview'] = data['current']
            if state == 'revision-two-read': data['ack'] = 2
            if state == 'revision-three-read': data['ack'] = 3
            if state == 'withdrawn':
                data['withdrawn'] = True
                data['preview'] = None
    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('revision-one-read / revision-two-arrives', solve('revision-one-read', [('revision-two-arrives', N)], N), 'revision-two-unread')
check('revision-two-unread / open-revision', solve('revision-two-unread', [('open-revision', N)], N), 'revision-two-preview')
check('revision-two-preview / ack-revision', solve('revision-two-preview', [('ack-revision', N)], N), 'revision-two-read')
check('revision-two-preview / revision-three-arrives', solve('revision-two-preview', [('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('revision-three-pending-review / accept-update', solve('revision-three-pending-review', [('accept-update', N)], N), 'revision-three-preview')
check('revision-three-preview / ack-revision', solve('revision-three-preview', [('ack-revision', N)], N), 'revision-three-read')
check('revision-three-read / late-revision-two', solve('revision-three-read', [('late-revision-two', N)], N), 'revision-three-read')
check('revision-three-pending-review / close-preview', solve('revision-three-pending-review', [('close-preview', N)], N), 'revision-three-unread')
check('revision-three-unread / open-revision', solve('revision-three-unread', [('open-revision', N)], N), 'revision-three-preview')
check('revision-two-unread / revision-withdrawn', solve('revision-two-unread', [('revision-withdrawn', N)], N), 'withdrawn')
check('older notification incarnation', solve('revision-one-read', [('revision-two-arrives', N - 1)], N), 'revision-one-read')
check('future notification incarnation', solve('revision-one-read', [('revision-two-arrives', N + 1)], N), 'revision-one-read')
check('unknown event is inert', solve('revision-one-read', [('unknown-event', N)], N), 'revision-one-read')
check('empty delivery batch', solve('revision-one-read', [], N), 'revision-one-read')
check('N stale deliveries before current delivery', solve('revision-one-read', [('revision-two-arrives', N - 1)] * N + [('revision-two-arrives', N)], N), 'revision-two-unread')
check('trace revision-two-arrives then open-revision', solve('revision-one-read', [('revision-two-arrives', N), ('open-revision', N)], N), 'revision-two-preview')
check('trace revision-two-arrives then revision-withdrawn', solve('revision-one-read', [('revision-two-arrives', N), ('revision-withdrawn', N)], N), 'withdrawn')
check('trace open-revision then ack-revision', solve('revision-two-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-two-read')
check('trace open-revision then revision-three-arrives', solve('revision-two-unread', [('open-revision', N), ('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('trace revision-three-arrives then accept-update', solve('revision-two-preview', [('revision-three-arrives', N), ('accept-update', N)], N), 'revision-three-preview')
check('trace revision-three-arrives then close-preview', solve('revision-two-preview', [('revision-three-arrives', N), ('close-preview', N)], N), 'revision-three-unread')
check('trace accept-update then ack-revision', solve('revision-three-pending-review', [('accept-update', N), ('ack-revision', N)], N), 'revision-three-read')
check('trace ack-revision then late-revision-two', solve('revision-three-preview', [('ack-revision', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace late-revision-two then late-revision-two', solve('revision-three-read', [('late-revision-two', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace close-preview then open-revision', solve('revision-three-pending-review', [('close-preview', N), ('open-revision', N)], N), 'revision-three-preview')
check('trace open-revision then ack-revision', solve('revision-three-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-three-read')
check('domain state regression 1: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 1})], N, {}, 'ack'), {'phase': 'revision-two-preview', 'value': 1})
check('domain state regression 2: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 2})], N, {}, 'ack'), {'phase': 'revision-two-read', 'value': 2})
check('domain state regression 3: preview', solve('revision-two-preview', [('revision-three-arrives', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'revision-three-pending-review', 'value': 2})
check('domain state regression 4: preview', solve('revision-three-pending-review', [('accept-update', N, {})], N, {'current': 3, 'preview': 2}, 'preview'), {'phase': 'revision-three-preview', 'value': 3})
check('domain state regression 5: current', solve('revision-three-read', [('late-revision-two', N, {})], N, {'current': 3, 'ack': 3}, 'current'), {'phase': 'revision-three-read', 'value': 3})
check('domain state regression 6: preview', solve('revision-two-unread', [('revision-withdrawn', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'withdrawn', 'value': None})
check('domain state regression 7: ack', solve('revision-two-preview', [('revision-three-arrives', N, {}), ('accept-update', N, {}), ('ack-revision', N, {'revision': 2}), ('ack-revision', N, {'revision': 3})], N, {}, 'ack'), {'phase': 'revision-three-read', 'value': 3})
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 open-revision event leaves a notification in revision-two-preview instead of revision-three-preview.

Notification content revision review is a bounded visual-notification workflow with mutable policy state {'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False}. Its default transition relation is {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}; 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 = {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'revision-two-read'}
    data = json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False})) if payload is None else {**json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': 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 == 'ack-revision' and arg.get('revision',data['current']) != data['current']: event = 'unknown-event'
            if event == 'revision-three-arrives': data['current'] = 3
            state = table.get((state, event), state)
            if state in ('revision-two-preview','revision-three-preview'): data['preview'] = data['current']
            if state == 'revision-two-read': data['ack'] = 2
            if state == 'revision-three-read': data['ack'] = 3
            if state == 'withdrawn':
                data['withdrawn'] = True
                data['preview'] = None
    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('revision-one-read / revision-two-arrives', solve('revision-one-read', [('revision-two-arrives', N)], N), 'revision-two-unread')
check('revision-two-unread / open-revision', solve('revision-two-unread', [('open-revision', N)], N), 'revision-two-preview')
check('revision-two-preview / ack-revision', solve('revision-two-preview', [('ack-revision', N)], N), 'revision-two-read')
check('revision-two-preview / revision-three-arrives', solve('revision-two-preview', [('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('revision-three-pending-review / accept-update', solve('revision-three-pending-review', [('accept-update', N)], N), 'revision-three-preview')
check('revision-three-preview / ack-revision', solve('revision-three-preview', [('ack-revision', N)], N), 'revision-three-read')
check('revision-three-read / late-revision-two', solve('revision-three-read', [('late-revision-two', N)], N), 'revision-three-read')
check('revision-three-pending-review / close-preview', solve('revision-three-pending-review', [('close-preview', N)], N), 'revision-three-unread')
check('revision-three-unread / open-revision', solve('revision-three-unread', [('open-revision', N)], N), 'revision-three-preview')
check('revision-two-unread / revision-withdrawn', solve('revision-two-unread', [('revision-withdrawn', N)], N), 'withdrawn')
check('older notification incarnation', solve('revision-one-read', [('revision-two-arrives', N - 1)], N), 'revision-one-read')
check('future notification incarnation', solve('revision-one-read', [('revision-two-arrives', N + 1)], N), 'revision-one-read')
check('unknown event is inert', solve('revision-one-read', [('unknown-event', N)], N), 'revision-one-read')
check('empty delivery batch', solve('revision-one-read', [], N), 'revision-one-read')
check('N stale deliveries before current delivery', solve('revision-one-read', [('revision-two-arrives', N - 1)] * N + [('revision-two-arrives', N)], N), 'revision-two-unread')
check('trace revision-two-arrives then open-revision', solve('revision-one-read', [('revision-two-arrives', N), ('open-revision', N)], N), 'revision-two-preview')
check('trace revision-two-arrives then revision-withdrawn', solve('revision-one-read', [('revision-two-arrives', N), ('revision-withdrawn', N)], N), 'withdrawn')
check('trace open-revision then ack-revision', solve('revision-two-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-two-read')
check('trace open-revision then revision-three-arrives', solve('revision-two-unread', [('open-revision', N), ('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('trace revision-three-arrives then accept-update', solve('revision-two-preview', [('revision-three-arrives', N), ('accept-update', N)], N), 'revision-three-preview')
check('trace revision-three-arrives then close-preview', solve('revision-two-preview', [('revision-three-arrives', N), ('close-preview', N)], N), 'revision-three-unread')
check('trace accept-update then ack-revision', solve('revision-three-pending-review', [('accept-update', N), ('ack-revision', N)], N), 'revision-three-read')
check('trace ack-revision then late-revision-two', solve('revision-three-preview', [('ack-revision', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace late-revision-two then late-revision-two', solve('revision-three-read', [('late-revision-two', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace close-preview then open-revision', solve('revision-three-pending-review', [('close-preview', N), ('open-revision', N)], N), 'revision-three-preview')
check('trace open-revision then ack-revision', solve('revision-three-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-three-read')
check('domain state regression 1: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 1})], N, {}, 'ack'), {'phase': 'revision-two-preview', 'value': 1})
check('domain state regression 2: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 2})], N, {}, 'ack'), {'phase': 'revision-two-read', 'value': 2})
check('domain state regression 3: preview', solve('revision-two-preview', [('revision-three-arrives', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'revision-three-pending-review', 'value': 2})
check('domain state regression 4: preview', solve('revision-three-pending-review', [('accept-update', N, {})], N, {'current': 3, 'preview': 2}, 'preview'), {'phase': 'revision-three-preview', 'value': 3})
check('domain state regression 5: current', solve('revision-three-read', [('late-revision-two', N, {})], N, {'current': 3, 'ack': 3}, 'current'), {'phase': 'revision-three-read', 'value': 3})
check('domain state regression 6: preview', solve('revision-two-unread', [('revision-withdrawn', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'withdrawn', 'value': None})
check('domain state regression 7: ack', solve('revision-two-preview', [('revision-three-arrives', N, {}), ('accept-update', N, {}), ('ack-revision', N, {'revision': 2}), ('ack-revision', N, {'revision': 3})], N, {}, 'ack'), {'phase': 'revision-three-read', 'value': 3})
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 = {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'revision-one-read'}
    data = json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False})) if payload is None else {**json.loads(json.dumps({'current': 2, 'ack': 1, 'preview': None, 'withdrawn': 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 == 'ack-revision' and arg.get('revision',data['current']) != data['current']: event = 'unknown-event'
            if event == 'revision-three-arrives': data['current'] = 3
            state = table.get((state, event), state)
            if state in ('revision-two-preview','revision-three-preview'): data['preview'] = data['current']
            if state == 'revision-two-read': data['ack'] = 2
            if state == 'revision-three-read': data['ack'] = 3
            if state == 'withdrawn':
                data['withdrawn'] = True
                data['preview'] = None
    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('revision-one-read / revision-two-arrives', solve('revision-one-read', [('revision-two-arrives', N)], N), 'revision-two-unread')
check('revision-two-unread / open-revision', solve('revision-two-unread', [('open-revision', N)], N), 'revision-two-preview')
check('revision-two-preview / ack-revision', solve('revision-two-preview', [('ack-revision', N)], N), 'revision-two-read')
check('revision-two-preview / revision-three-arrives', solve('revision-two-preview', [('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('revision-three-pending-review / accept-update', solve('revision-three-pending-review', [('accept-update', N)], N), 'revision-three-preview')
check('revision-three-preview / ack-revision', solve('revision-three-preview', [('ack-revision', N)], N), 'revision-three-read')
check('revision-three-read / late-revision-two', solve('revision-three-read', [('late-revision-two', N)], N), 'revision-three-read')
check('revision-three-pending-review / close-preview', solve('revision-three-pending-review', [('close-preview', N)], N), 'revision-three-unread')
check('revision-three-unread / open-revision', solve('revision-three-unread', [('open-revision', N)], N), 'revision-three-preview')
check('revision-two-unread / revision-withdrawn', solve('revision-two-unread', [('revision-withdrawn', N)], N), 'withdrawn')
check('older notification incarnation', solve('revision-one-read', [('revision-two-arrives', N - 1)], N), 'revision-one-read')
check('future notification incarnation', solve('revision-one-read', [('revision-two-arrives', N + 1)], N), 'revision-one-read')
check('unknown event is inert', solve('revision-one-read', [('unknown-event', N)], N), 'revision-one-read')
check('empty delivery batch', solve('revision-one-read', [], N), 'revision-one-read')
check('N stale deliveries before current delivery', solve('revision-one-read', [('revision-two-arrives', N - 1)] * N + [('revision-two-arrives', N)], N), 'revision-two-unread')
check('trace revision-two-arrives then open-revision', solve('revision-one-read', [('revision-two-arrives', N), ('open-revision', N)], N), 'revision-two-preview')
check('trace revision-two-arrives then revision-withdrawn', solve('revision-one-read', [('revision-two-arrives', N), ('revision-withdrawn', N)], N), 'withdrawn')
check('trace open-revision then ack-revision', solve('revision-two-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-two-read')
check('trace open-revision then revision-three-arrives', solve('revision-two-unread', [('open-revision', N), ('revision-three-arrives', N)], N), 'revision-three-pending-review')
check('trace revision-three-arrives then accept-update', solve('revision-two-preview', [('revision-three-arrives', N), ('accept-update', N)], N), 'revision-three-preview')
check('trace revision-three-arrives then close-preview', solve('revision-two-preview', [('revision-three-arrives', N), ('close-preview', N)], N), 'revision-three-unread')
check('trace accept-update then ack-revision', solve('revision-three-pending-review', [('accept-update', N), ('ack-revision', N)], N), 'revision-three-read')
check('trace ack-revision then late-revision-two', solve('revision-three-preview', [('ack-revision', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace late-revision-two then late-revision-two', solve('revision-three-read', [('late-revision-two', N), ('late-revision-two', N)], N), 'revision-three-read')
check('trace close-preview then open-revision', solve('revision-three-pending-review', [('close-preview', N), ('open-revision', N)], N), 'revision-three-preview')
check('trace open-revision then ack-revision', solve('revision-three-unread', [('open-revision', N), ('ack-revision', N)], N), 'revision-three-read')
check('domain state regression 1: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 1})], N, {}, 'ack'), {'phase': 'revision-two-preview', 'value': 1})
check('domain state regression 2: ack', solve('revision-two-preview', [('ack-revision', N, {'revision': 2})], N, {}, 'ack'), {'phase': 'revision-two-read', 'value': 2})
check('domain state regression 3: preview', solve('revision-two-preview', [('revision-three-arrives', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'revision-three-pending-review', 'value': 2})
check('domain state regression 4: preview', solve('revision-three-pending-review', [('accept-update', N, {})], N, {'current': 3, 'preview': 2}, 'preview'), {'phase': 'revision-three-preview', 'value': 3})
check('domain state regression 5: current', solve('revision-three-read', [('late-revision-two', N, {})], N, {'current': 3, 'ack': 3}, 'current'), {'phase': 'revision-three-read', 'value': 3})
check('domain state regression 6: preview', solve('revision-two-unread', [('revision-withdrawn', N, {})], N, {'preview': 2}, 'preview'), {'phase': 'withdrawn', 'value': None})
check('domain state regression 7: ack', solve('revision-two-preview', [('revision-three-arrives', N, {}), ('accept-update', N, {}), ('ack-revision', N, {'revision': 2}), ('ack-revision', N, {'revision': 3})], N, {}, 'ack'), {'phase': 'revision-three-read', 'value': 3})
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 revision-withdrawn event leaves a notification in revision-two-read instead of withdrawn.

Notification content revision review is a bounded visual-notification workflow with mutable policy state {'current': 2, 'ack': 1, 'preview': None, 'withdrawn': False}. Its default transition relation is {('revision-one-read', 'revision-two-arrives'): 'revision-two-unread', ('revision-two-unread', 'open-revision'): 'revision-two-preview', ('revision-two-preview', 'ack-revision'): 'revision-two-read', ('revision-two-preview', 'revision-three-arrives'): 'revision-three-pending-review', ('revision-three-pending-review', 'accept-update'): 'revision-three-preview', ('revision-three-preview', 'ack-revision'): 'revision-three-read', ('revision-three-read', 'late-revision-two'): 'revision-three-read', ('revision-three-pending-review', 'close-preview'): 'revision-three-unread', ('revision-three-unread', 'open-revision'): 'revision-three-preview', ('revision-two-unread', 'revision-withdrawn'): 'withdrawn'}; 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