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 = {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'remote-visible', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}
    data = json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})) if payload is None else {**json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('remote-accepted','remote-painted','remote-released','remote-rejected','remote-paint-failed'):
                if arg.get('transfer',data['transfer']) != data['transfer'] or arg.get('owner',data['remote_owner']) != data['remote_owner']: event = 'unknown-event'
            if event == 'remote-painted': data['remote'] = True
            if event == 'remote-released': data['remote'] = False
            state = table.get((state, event), state)
            if state == 'remote-visible': data['local'] = False
            if state in ('local-visible','handoff-error'): data['local'] = True
            if state == 'local-hidden': data['local'] = False
    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('local-visible / send-to-other-surface', solve('local-visible', [('send-to-other-surface', N)], N), 'handoff-pending')
check('handoff-pending / remote-accepted', solve('handoff-pending', [('remote-accepted', N)], N), 'remote-mounting')
check('remote-mounting / remote-painted', solve('remote-mounting', [('remote-painted', N)], N), 'remote-visible')
check('remote-mounting / remote-paint-failed', solve('remote-mounting', [('remote-paint-failed', N)], N), 'handoff-error')
check('handoff-pending / remote-rejected', solve('handoff-pending', [('remote-rejected', N)], N), 'handoff-error')
check('handoff-error / retry-handoff', solve('handoff-error', [('retry-handoff', N)], N), 'handoff-pending')
check('remote-visible / bring-back', solve('remote-visible', [('bring-back', N)], N), 'recall-pending')
check('recall-pending / remote-released', solve('recall-pending', [('remote-released', N)], N), 'local-remounting')
check('local-remounting / local-painted', solve('local-remounting', [('local-painted', N)], N), 'local-visible')
check('handoff-pending / cancel-handoff', solve('handoff-pending', [('cancel-handoff', N)], N), 'cancel-pending')
check('older notification incarnation', solve('local-visible', [('send-to-other-surface', N - 1)], N), 'local-visible')
check('future notification incarnation', solve('local-visible', [('send-to-other-surface', N + 1)], N), 'local-visible')
check('unknown event is inert', solve('local-visible', [('unknown-event', N)], N), 'local-visible')
check('empty delivery batch', solve('local-visible', [], N), 'local-visible')
check('N stale deliveries before current delivery', solve('local-visible', [('send-to-other-surface', N - 1)] * N + [('send-to-other-surface', N)], N), 'handoff-pending')
check('trace send-to-other-surface then remote-accepted', solve('local-visible', [('send-to-other-surface', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace send-to-other-surface then remote-rejected', solve('local-visible', [('send-to-other-surface', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace send-to-other-surface then cancel-handoff', solve('local-visible', [('send-to-other-surface', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace remote-accepted then remote-painted', solve('handoff-pending', [('remote-accepted', N), ('remote-painted', N)], N), 'remote-visible')
check('trace remote-accepted then remote-paint-failed', solve('handoff-pending', [('remote-accepted', N), ('remote-paint-failed', N)], N), 'handoff-error')
check('trace remote-painted then bring-back', solve('remote-mounting', [('remote-painted', N), ('bring-back', N)], N), 'recall-pending')
check('trace remote-paint-failed then retry-handoff', solve('remote-mounting', [('remote-paint-failed', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace remote-rejected then retry-handoff', solve('handoff-pending', [('remote-rejected', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace retry-handoff then remote-accepted', solve('handoff-error', [('retry-handoff', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace retry-handoff then remote-rejected', solve('handoff-error', [('retry-handoff', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace retry-handoff then cancel-handoff', solve('handoff-error', [('retry-handoff', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace bring-back then remote-released', solve('remote-visible', [('bring-back', N), ('remote-released', N)], N), 'local-remounting')
check('trace remote-released then local-painted', solve('recall-pending', [('remote-released', N), ('local-painted', N)], N), 'local-visible')
check('trace local-painted then send-to-other-surface', solve('local-remounting', [('local-painted', N), ('send-to-other-surface', N)], N), 'handoff-pending')
check('domain state regression 1: local', solve('handoff-pending', [('remote-accepted', N, {'transfer': 3})], N, {}, 'local'), {'phase': 'handoff-pending', 'value': True})
check('domain state regression 2: remote', solve('remote-mounting', [('remote-painted', N, {'owner': 'phone'})], N, {}, 'remote'), {'phase': 'remote-mounting', 'value': False})
check('domain state regression 3: local', solve('remote-mounting', [('remote-painted', N, {})], N, {}, 'local'), {'phase': 'remote-visible', 'value': False})
check('domain state regression 4: local', solve('remote-mounting', [('remote-paint-failed', N, {})], N, {}, 'local'), {'phase': 'handoff-error', 'value': True})
check('domain state regression 5: remote', solve('recall-pending', [('remote-released', N, {})], N, {'local': False, 'remote': True}, 'remote'), {'phase': 'local-remounting', 'value': False})
check('domain state regression 6: local', solve('local-remounting', [('local-painted', N, {})], N, {'local': False, 'remote': False}, 'local'), {'phase': 'local-visible', 'value': True})
check('domain state regression 7: remote', solve('local-visible', [('send-to-other-surface', N, {}), ('remote-accepted', N, {}), ('remote-painted', N, {}), ('bring-back', N, {}), ('remote-released', N, {}), ('local-painted', N, {})], N, {}, 'remote'), {'phase': 'local-visible', 'value': False})
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 = {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'local-hidden', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}
    data = json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})) if payload is None else {**json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('remote-accepted','remote-painted','remote-released','remote-rejected','remote-paint-failed'):
                if arg.get('transfer',data['transfer']) != data['transfer'] or arg.get('owner',data['remote_owner']) != data['remote_owner']: event = 'unknown-event'
            if event == 'remote-painted': data['remote'] = True
            if event == 'remote-released': data['remote'] = False
            state = table.get((state, event), state)
            if state == 'remote-visible': data['local'] = False
            if state in ('local-visible','handoff-error'): data['local'] = True
            if state == 'local-hidden': data['local'] = False
    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('local-visible / send-to-other-surface', solve('local-visible', [('send-to-other-surface', N)], N), 'handoff-pending')
check('handoff-pending / remote-accepted', solve('handoff-pending', [('remote-accepted', N)], N), 'remote-mounting')
check('remote-mounting / remote-painted', solve('remote-mounting', [('remote-painted', N)], N), 'remote-visible')
check('remote-mounting / remote-paint-failed', solve('remote-mounting', [('remote-paint-failed', N)], N), 'handoff-error')
check('handoff-pending / remote-rejected', solve('handoff-pending', [('remote-rejected', N)], N), 'handoff-error')
check('handoff-error / retry-handoff', solve('handoff-error', [('retry-handoff', N)], N), 'handoff-pending')
check('remote-visible / bring-back', solve('remote-visible', [('bring-back', N)], N), 'recall-pending')
check('recall-pending / remote-released', solve('recall-pending', [('remote-released', N)], N), 'local-remounting')
check('local-remounting / local-painted', solve('local-remounting', [('local-painted', N)], N), 'local-visible')
check('handoff-pending / cancel-handoff', solve('handoff-pending', [('cancel-handoff', N)], N), 'cancel-pending')
check('older notification incarnation', solve('local-visible', [('send-to-other-surface', N - 1)], N), 'local-visible')
check('future notification incarnation', solve('local-visible', [('send-to-other-surface', N + 1)], N), 'local-visible')
check('unknown event is inert', solve('local-visible', [('unknown-event', N)], N), 'local-visible')
check('empty delivery batch', solve('local-visible', [], N), 'local-visible')
check('N stale deliveries before current delivery', solve('local-visible', [('send-to-other-surface', N - 1)] * N + [('send-to-other-surface', N)], N), 'handoff-pending')
check('trace send-to-other-surface then remote-accepted', solve('local-visible', [('send-to-other-surface', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace send-to-other-surface then remote-rejected', solve('local-visible', [('send-to-other-surface', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace send-to-other-surface then cancel-handoff', solve('local-visible', [('send-to-other-surface', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace remote-accepted then remote-painted', solve('handoff-pending', [('remote-accepted', N), ('remote-painted', N)], N), 'remote-visible')
check('trace remote-accepted then remote-paint-failed', solve('handoff-pending', [('remote-accepted', N), ('remote-paint-failed', N)], N), 'handoff-error')
check('trace remote-painted then bring-back', solve('remote-mounting', [('remote-painted', N), ('bring-back', N)], N), 'recall-pending')
check('trace remote-paint-failed then retry-handoff', solve('remote-mounting', [('remote-paint-failed', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace remote-rejected then retry-handoff', solve('handoff-pending', [('remote-rejected', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace retry-handoff then remote-accepted', solve('handoff-error', [('retry-handoff', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace retry-handoff then remote-rejected', solve('handoff-error', [('retry-handoff', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace retry-handoff then cancel-handoff', solve('handoff-error', [('retry-handoff', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace bring-back then remote-released', solve('remote-visible', [('bring-back', N), ('remote-released', N)], N), 'local-remounting')
check('trace remote-released then local-painted', solve('recall-pending', [('remote-released', N), ('local-painted', N)], N), 'local-visible')
check('trace local-painted then send-to-other-surface', solve('local-remounting', [('local-painted', N), ('send-to-other-surface', N)], N), 'handoff-pending')
check('domain state regression 1: local', solve('handoff-pending', [('remote-accepted', N, {'transfer': 3})], N, {}, 'local'), {'phase': 'handoff-pending', 'value': True})
check('domain state regression 2: remote', solve('remote-mounting', [('remote-painted', N, {'owner': 'phone'})], N, {}, 'remote'), {'phase': 'remote-mounting', 'value': False})
check('domain state regression 3: local', solve('remote-mounting', [('remote-painted', N, {})], N, {}, 'local'), {'phase': 'remote-visible', 'value': False})
check('domain state regression 4: local', solve('remote-mounting', [('remote-paint-failed', N, {})], N, {}, 'local'), {'phase': 'handoff-error', 'value': True})
check('domain state regression 5: remote', solve('recall-pending', [('remote-released', N, {})], N, {'local': False, 'remote': True}, 'remote'), {'phase': 'local-remounting', 'value': False})
check('domain state regression 6: local', solve('local-remounting', [('local-painted', N, {})], N, {'local': False, 'remote': False}, 'local'), {'phase': 'local-visible', 'value': True})
check('domain state regression 7: remote', solve('local-visible', [('send-to-other-surface', N, {}), ('remote-accepted', N, {}), ('remote-painted', N, {}), ('bring-back', N, {}), ('remote-released', N, {}), ('local-painted', N, {})], N, {}, 'remote'), {'phase': 'local-visible', 'value': False})
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 retry-handoff event leaves a notification in remote-visible instead of handoff-pending.

Notification handoff to another surface is a bounded visual-notification workflow with mutable policy state {'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'}. Its default transition relation is {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}; 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 = {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'local-visible', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}
    data = json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})) if payload is None else {**json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('remote-accepted','remote-painted','remote-released','remote-rejected','remote-paint-failed'):
                if arg.get('transfer',data['transfer']) != data['transfer'] or arg.get('owner',data['remote_owner']) != data['remote_owner']: event = 'unknown-event'
            if event == 'remote-painted': data['remote'] = True
            if event == 'remote-released': data['remote'] = False
            state = table.get((state, event), state)
            if state == 'remote-visible': data['local'] = False
            if state in ('local-visible','handoff-error'): data['local'] = True
            if state == 'local-hidden': data['local'] = False
    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('local-visible / send-to-other-surface', solve('local-visible', [('send-to-other-surface', N)], N), 'handoff-pending')
check('handoff-pending / remote-accepted', solve('handoff-pending', [('remote-accepted', N)], N), 'remote-mounting')
check('remote-mounting / remote-painted', solve('remote-mounting', [('remote-painted', N)], N), 'remote-visible')
check('remote-mounting / remote-paint-failed', solve('remote-mounting', [('remote-paint-failed', N)], N), 'handoff-error')
check('handoff-pending / remote-rejected', solve('handoff-pending', [('remote-rejected', N)], N), 'handoff-error')
check('handoff-error / retry-handoff', solve('handoff-error', [('retry-handoff', N)], N), 'handoff-pending')
check('remote-visible / bring-back', solve('remote-visible', [('bring-back', N)], N), 'recall-pending')
check('recall-pending / remote-released', solve('recall-pending', [('remote-released', N)], N), 'local-remounting')
check('local-remounting / local-painted', solve('local-remounting', [('local-painted', N)], N), 'local-visible')
check('handoff-pending / cancel-handoff', solve('handoff-pending', [('cancel-handoff', N)], N), 'cancel-pending')
check('older notification incarnation', solve('local-visible', [('send-to-other-surface', N - 1)], N), 'local-visible')
check('future notification incarnation', solve('local-visible', [('send-to-other-surface', N + 1)], N), 'local-visible')
check('unknown event is inert', solve('local-visible', [('unknown-event', N)], N), 'local-visible')
check('empty delivery batch', solve('local-visible', [], N), 'local-visible')
check('N stale deliveries before current delivery', solve('local-visible', [('send-to-other-surface', N - 1)] * N + [('send-to-other-surface', N)], N), 'handoff-pending')
check('trace send-to-other-surface then remote-accepted', solve('local-visible', [('send-to-other-surface', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace send-to-other-surface then remote-rejected', solve('local-visible', [('send-to-other-surface', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace send-to-other-surface then cancel-handoff', solve('local-visible', [('send-to-other-surface', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace remote-accepted then remote-painted', solve('handoff-pending', [('remote-accepted', N), ('remote-painted', N)], N), 'remote-visible')
check('trace remote-accepted then remote-paint-failed', solve('handoff-pending', [('remote-accepted', N), ('remote-paint-failed', N)], N), 'handoff-error')
check('trace remote-painted then bring-back', solve('remote-mounting', [('remote-painted', N), ('bring-back', N)], N), 'recall-pending')
check('trace remote-paint-failed then retry-handoff', solve('remote-mounting', [('remote-paint-failed', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace remote-rejected then retry-handoff', solve('handoff-pending', [('remote-rejected', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace retry-handoff then remote-accepted', solve('handoff-error', [('retry-handoff', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace retry-handoff then remote-rejected', solve('handoff-error', [('retry-handoff', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace retry-handoff then cancel-handoff', solve('handoff-error', [('retry-handoff', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace bring-back then remote-released', solve('remote-visible', [('bring-back', N), ('remote-released', N)], N), 'local-remounting')
check('trace remote-released then local-painted', solve('recall-pending', [('remote-released', N), ('local-painted', N)], N), 'local-visible')
check('trace local-painted then send-to-other-surface', solve('local-remounting', [('local-painted', N), ('send-to-other-surface', N)], N), 'handoff-pending')
check('domain state regression 1: local', solve('handoff-pending', [('remote-accepted', N, {'transfer': 3})], N, {}, 'local'), {'phase': 'handoff-pending', 'value': True})
check('domain state regression 2: remote', solve('remote-mounting', [('remote-painted', N, {'owner': 'phone'})], N, {}, 'remote'), {'phase': 'remote-mounting', 'value': False})
check('domain state regression 3: local', solve('remote-mounting', [('remote-painted', N, {})], N, {}, 'local'), {'phase': 'remote-visible', 'value': False})
check('domain state regression 4: local', solve('remote-mounting', [('remote-paint-failed', N, {})], N, {}, 'local'), {'phase': 'handoff-error', 'value': True})
check('domain state regression 5: remote', solve('recall-pending', [('remote-released', N, {})], N, {'local': False, 'remote': True}, 'remote'), {'phase': 'local-remounting', 'value': False})
check('domain state regression 6: local', solve('local-remounting', [('local-painted', N, {})], N, {'local': False, 'remote': False}, 'local'), {'phase': 'local-visible', 'value': True})
check('domain state regression 7: remote', solve('local-visible', [('send-to-other-surface', N, {}), ('remote-accepted', N, {}), ('remote-painted', N, {}), ('bring-back', N, {}), ('remote-released', N, {}), ('local-painted', N, {})], N, {}, 'remote'), {'phase': 'local-visible', 'value': False})
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 = {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'local-hidden', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}
    data = json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})) if payload is None else {**json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('remote-accepted','remote-painted','remote-released','remote-rejected','remote-paint-failed'):
                if arg.get('transfer',data['transfer']) != data['transfer'] or arg.get('owner',data['remote_owner']) != data['remote_owner']: event = 'unknown-event'
            if event == 'remote-painted': data['remote'] = True
            if event == 'remote-released': data['remote'] = False
            state = table.get((state, event), state)
            if state == 'remote-visible': data['local'] = False
            if state in ('local-visible','handoff-error'): data['local'] = True
            if state == 'local-hidden': data['local'] = False
    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('local-visible / send-to-other-surface', solve('local-visible', [('send-to-other-surface', N)], N), 'handoff-pending')
check('handoff-pending / remote-accepted', solve('handoff-pending', [('remote-accepted', N)], N), 'remote-mounting')
check('remote-mounting / remote-painted', solve('remote-mounting', [('remote-painted', N)], N), 'remote-visible')
check('remote-mounting / remote-paint-failed', solve('remote-mounting', [('remote-paint-failed', N)], N), 'handoff-error')
check('handoff-pending / remote-rejected', solve('handoff-pending', [('remote-rejected', N)], N), 'handoff-error')
check('handoff-error / retry-handoff', solve('handoff-error', [('retry-handoff', N)], N), 'handoff-pending')
check('remote-visible / bring-back', solve('remote-visible', [('bring-back', N)], N), 'recall-pending')
check('recall-pending / remote-released', solve('recall-pending', [('remote-released', N)], N), 'local-remounting')
check('local-remounting / local-painted', solve('local-remounting', [('local-painted', N)], N), 'local-visible')
check('handoff-pending / cancel-handoff', solve('handoff-pending', [('cancel-handoff', N)], N), 'cancel-pending')
check('older notification incarnation', solve('local-visible', [('send-to-other-surface', N - 1)], N), 'local-visible')
check('future notification incarnation', solve('local-visible', [('send-to-other-surface', N + 1)], N), 'local-visible')
check('unknown event is inert', solve('local-visible', [('unknown-event', N)], N), 'local-visible')
check('empty delivery batch', solve('local-visible', [], N), 'local-visible')
check('N stale deliveries before current delivery', solve('local-visible', [('send-to-other-surface', N - 1)] * N + [('send-to-other-surface', N)], N), 'handoff-pending')
check('trace send-to-other-surface then remote-accepted', solve('local-visible', [('send-to-other-surface', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace send-to-other-surface then remote-rejected', solve('local-visible', [('send-to-other-surface', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace send-to-other-surface then cancel-handoff', solve('local-visible', [('send-to-other-surface', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace remote-accepted then remote-painted', solve('handoff-pending', [('remote-accepted', N), ('remote-painted', N)], N), 'remote-visible')
check('trace remote-accepted then remote-paint-failed', solve('handoff-pending', [('remote-accepted', N), ('remote-paint-failed', N)], N), 'handoff-error')
check('trace remote-painted then bring-back', solve('remote-mounting', [('remote-painted', N), ('bring-back', N)], N), 'recall-pending')
check('trace remote-paint-failed then retry-handoff', solve('remote-mounting', [('remote-paint-failed', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace remote-rejected then retry-handoff', solve('handoff-pending', [('remote-rejected', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace retry-handoff then remote-accepted', solve('handoff-error', [('retry-handoff', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace retry-handoff then remote-rejected', solve('handoff-error', [('retry-handoff', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace retry-handoff then cancel-handoff', solve('handoff-error', [('retry-handoff', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace bring-back then remote-released', solve('remote-visible', [('bring-back', N), ('remote-released', N)], N), 'local-remounting')
check('trace remote-released then local-painted', solve('recall-pending', [('remote-released', N), ('local-painted', N)], N), 'local-visible')
check('trace local-painted then send-to-other-surface', solve('local-remounting', [('local-painted', N), ('send-to-other-surface', N)], N), 'handoff-pending')
check('domain state regression 1: local', solve('handoff-pending', [('remote-accepted', N, {'transfer': 3})], N, {}, 'local'), {'phase': 'handoff-pending', 'value': True})
check('domain state regression 2: remote', solve('remote-mounting', [('remote-painted', N, {'owner': 'phone'})], N, {}, 'remote'), {'phase': 'remote-mounting', 'value': False})
check('domain state regression 3: local', solve('remote-mounting', [('remote-painted', N, {})], N, {}, 'local'), {'phase': 'remote-visible', 'value': False})
check('domain state regression 4: local', solve('remote-mounting', [('remote-paint-failed', N, {})], N, {}, 'local'), {'phase': 'handoff-error', 'value': True})
check('domain state regression 5: remote', solve('recall-pending', [('remote-released', N, {})], N, {'local': False, 'remote': True}, 'remote'), {'phase': 'local-remounting', 'value': False})
check('domain state regression 6: local', solve('local-remounting', [('local-painted', N, {})], N, {'local': False, 'remote': False}, 'local'), {'phase': 'local-visible', 'value': True})
check('domain state regression 7: remote', solve('local-visible', [('send-to-other-surface', N, {}), ('remote-accepted', N, {}), ('remote-painted', N, {}), ('bring-back', N, {}), ('remote-released', N, {}), ('local-painted', N, {})], N, {}, 'remote'), {'phase': 'local-visible', 'value': False})
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 bring-back event leaves a notification in local-visible instead of recall-pending.

Notification handoff to another surface is a bounded visual-notification workflow with mutable policy state {'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'}. Its default transition relation is {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}; 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 = {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'local-visible', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}
    data = json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})) if payload is None else {**json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('remote-accepted','remote-painted','remote-released','remote-rejected','remote-paint-failed'):
                if arg.get('transfer',data['transfer']) != data['transfer'] or arg.get('owner',data['remote_owner']) != data['remote_owner']: event = 'unknown-event'
            if event == 'remote-painted': data['remote'] = True
            if event == 'remote-released': data['remote'] = False
            state = table.get((state, event), state)
            if state == 'remote-visible': data['local'] = False
            if state in ('local-visible','handoff-error'): data['local'] = True
            if state == 'local-hidden': data['local'] = False
    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('local-visible / send-to-other-surface', solve('local-visible', [('send-to-other-surface', N)], N), 'handoff-pending')
check('handoff-pending / remote-accepted', solve('handoff-pending', [('remote-accepted', N)], N), 'remote-mounting')
check('remote-mounting / remote-painted', solve('remote-mounting', [('remote-painted', N)], N), 'remote-visible')
check('remote-mounting / remote-paint-failed', solve('remote-mounting', [('remote-paint-failed', N)], N), 'handoff-error')
check('handoff-pending / remote-rejected', solve('handoff-pending', [('remote-rejected', N)], N), 'handoff-error')
check('handoff-error / retry-handoff', solve('handoff-error', [('retry-handoff', N)], N), 'handoff-pending')
check('remote-visible / bring-back', solve('remote-visible', [('bring-back', N)], N), 'recall-pending')
check('recall-pending / remote-released', solve('recall-pending', [('remote-released', N)], N), 'local-remounting')
check('local-remounting / local-painted', solve('local-remounting', [('local-painted', N)], N), 'local-visible')
check('handoff-pending / cancel-handoff', solve('handoff-pending', [('cancel-handoff', N)], N), 'cancel-pending')
check('older notification incarnation', solve('local-visible', [('send-to-other-surface', N - 1)], N), 'local-visible')
check('future notification incarnation', solve('local-visible', [('send-to-other-surface', N + 1)], N), 'local-visible')
check('unknown event is inert', solve('local-visible', [('unknown-event', N)], N), 'local-visible')
check('empty delivery batch', solve('local-visible', [], N), 'local-visible')
check('N stale deliveries before current delivery', solve('local-visible', [('send-to-other-surface', N - 1)] * N + [('send-to-other-surface', N)], N), 'handoff-pending')
check('trace send-to-other-surface then remote-accepted', solve('local-visible', [('send-to-other-surface', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace send-to-other-surface then remote-rejected', solve('local-visible', [('send-to-other-surface', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace send-to-other-surface then cancel-handoff', solve('local-visible', [('send-to-other-surface', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace remote-accepted then remote-painted', solve('handoff-pending', [('remote-accepted', N), ('remote-painted', N)], N), 'remote-visible')
check('trace remote-accepted then remote-paint-failed', solve('handoff-pending', [('remote-accepted', N), ('remote-paint-failed', N)], N), 'handoff-error')
check('trace remote-painted then bring-back', solve('remote-mounting', [('remote-painted', N), ('bring-back', N)], N), 'recall-pending')
check('trace remote-paint-failed then retry-handoff', solve('remote-mounting', [('remote-paint-failed', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace remote-rejected then retry-handoff', solve('handoff-pending', [('remote-rejected', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace retry-handoff then remote-accepted', solve('handoff-error', [('retry-handoff', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace retry-handoff then remote-rejected', solve('handoff-error', [('retry-handoff', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace retry-handoff then cancel-handoff', solve('handoff-error', [('retry-handoff', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace bring-back then remote-released', solve('remote-visible', [('bring-back', N), ('remote-released', N)], N), 'local-remounting')
check('trace remote-released then local-painted', solve('recall-pending', [('remote-released', N), ('local-painted', N)], N), 'local-visible')
check('trace local-painted then send-to-other-surface', solve('local-remounting', [('local-painted', N), ('send-to-other-surface', N)], N), 'handoff-pending')
check('domain state regression 1: local', solve('handoff-pending', [('remote-accepted', N, {'transfer': 3})], N, {}, 'local'), {'phase': 'handoff-pending', 'value': True})
check('domain state regression 2: remote', solve('remote-mounting', [('remote-painted', N, {'owner': 'phone'})], N, {}, 'remote'), {'phase': 'remote-mounting', 'value': False})
check('domain state regression 3: local', solve('remote-mounting', [('remote-painted', N, {})], N, {}, 'local'), {'phase': 'remote-visible', 'value': False})
check('domain state regression 4: local', solve('remote-mounting', [('remote-paint-failed', N, {})], N, {}, 'local'), {'phase': 'handoff-error', 'value': True})
check('domain state regression 5: remote', solve('recall-pending', [('remote-released', N, {})], N, {'local': False, 'remote': True}, 'remote'), {'phase': 'local-remounting', 'value': False})
check('domain state regression 6: local', solve('local-remounting', [('local-painted', N, {})], N, {'local': False, 'remote': False}, 'local'), {'phase': 'local-visible', 'value': True})
check('domain state regression 7: remote', solve('local-visible', [('send-to-other-surface', N, {}), ('remote-accepted', N, {}), ('remote-painted', N, {}), ('bring-back', N, {}), ('remote-released', N, {}), ('local-painted', N, {})], N, {}, 'remote'), {'phase': 'local-visible', 'value': False})
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 = {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'remote-visible', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}
    data = json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})) if payload is None else {**json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('remote-accepted','remote-painted','remote-released','remote-rejected','remote-paint-failed'):
                if arg.get('transfer',data['transfer']) != data['transfer'] or arg.get('owner',data['remote_owner']) != data['remote_owner']: event = 'unknown-event'
            if event == 'remote-painted': data['remote'] = True
            if event == 'remote-released': data['remote'] = False
            state = table.get((state, event), state)
            if state == 'remote-visible': data['local'] = False
            if state in ('local-visible','handoff-error'): data['local'] = True
            if state == 'local-hidden': data['local'] = False
    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('local-visible / send-to-other-surface', solve('local-visible', [('send-to-other-surface', N)], N), 'handoff-pending')
check('handoff-pending / remote-accepted', solve('handoff-pending', [('remote-accepted', N)], N), 'remote-mounting')
check('remote-mounting / remote-painted', solve('remote-mounting', [('remote-painted', N)], N), 'remote-visible')
check('remote-mounting / remote-paint-failed', solve('remote-mounting', [('remote-paint-failed', N)], N), 'handoff-error')
check('handoff-pending / remote-rejected', solve('handoff-pending', [('remote-rejected', N)], N), 'handoff-error')
check('handoff-error / retry-handoff', solve('handoff-error', [('retry-handoff', N)], N), 'handoff-pending')
check('remote-visible / bring-back', solve('remote-visible', [('bring-back', N)], N), 'recall-pending')
check('recall-pending / remote-released', solve('recall-pending', [('remote-released', N)], N), 'local-remounting')
check('local-remounting / local-painted', solve('local-remounting', [('local-painted', N)], N), 'local-visible')
check('handoff-pending / cancel-handoff', solve('handoff-pending', [('cancel-handoff', N)], N), 'cancel-pending')
check('older notification incarnation', solve('local-visible', [('send-to-other-surface', N - 1)], N), 'local-visible')
check('future notification incarnation', solve('local-visible', [('send-to-other-surface', N + 1)], N), 'local-visible')
check('unknown event is inert', solve('local-visible', [('unknown-event', N)], N), 'local-visible')
check('empty delivery batch', solve('local-visible', [], N), 'local-visible')
check('N stale deliveries before current delivery', solve('local-visible', [('send-to-other-surface', N - 1)] * N + [('send-to-other-surface', N)], N), 'handoff-pending')
check('trace send-to-other-surface then remote-accepted', solve('local-visible', [('send-to-other-surface', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace send-to-other-surface then remote-rejected', solve('local-visible', [('send-to-other-surface', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace send-to-other-surface then cancel-handoff', solve('local-visible', [('send-to-other-surface', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace remote-accepted then remote-painted', solve('handoff-pending', [('remote-accepted', N), ('remote-painted', N)], N), 'remote-visible')
check('trace remote-accepted then remote-paint-failed', solve('handoff-pending', [('remote-accepted', N), ('remote-paint-failed', N)], N), 'handoff-error')
check('trace remote-painted then bring-back', solve('remote-mounting', [('remote-painted', N), ('bring-back', N)], N), 'recall-pending')
check('trace remote-paint-failed then retry-handoff', solve('remote-mounting', [('remote-paint-failed', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace remote-rejected then retry-handoff', solve('handoff-pending', [('remote-rejected', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace retry-handoff then remote-accepted', solve('handoff-error', [('retry-handoff', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace retry-handoff then remote-rejected', solve('handoff-error', [('retry-handoff', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace retry-handoff then cancel-handoff', solve('handoff-error', [('retry-handoff', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace bring-back then remote-released', solve('remote-visible', [('bring-back', N), ('remote-released', N)], N), 'local-remounting')
check('trace remote-released then local-painted', solve('recall-pending', [('remote-released', N), ('local-painted', N)], N), 'local-visible')
check('trace local-painted then send-to-other-surface', solve('local-remounting', [('local-painted', N), ('send-to-other-surface', N)], N), 'handoff-pending')
check('domain state regression 1: local', solve('handoff-pending', [('remote-accepted', N, {'transfer': 3})], N, {}, 'local'), {'phase': 'handoff-pending', 'value': True})
check('domain state regression 2: remote', solve('remote-mounting', [('remote-painted', N, {'owner': 'phone'})], N, {}, 'remote'), {'phase': 'remote-mounting', 'value': False})
check('domain state regression 3: local', solve('remote-mounting', [('remote-painted', N, {})], N, {}, 'local'), {'phase': 'remote-visible', 'value': False})
check('domain state regression 4: local', solve('remote-mounting', [('remote-paint-failed', N, {})], N, {}, 'local'), {'phase': 'handoff-error', 'value': True})
check('domain state regression 5: remote', solve('recall-pending', [('remote-released', N, {})], N, {'local': False, 'remote': True}, 'remote'), {'phase': 'local-remounting', 'value': False})
check('domain state regression 6: local', solve('local-remounting', [('local-painted', N, {})], N, {'local': False, 'remote': False}, 'local'), {'phase': 'local-visible', 'value': True})
check('domain state regression 7: remote', solve('local-visible', [('send-to-other-surface', N, {}), ('remote-accepted', N, {}), ('remote-painted', N, {}), ('bring-back', N, {}), ('remote-released', N, {}), ('local-painted', N, {})], N, {}, 'remote'), {'phase': 'local-visible', 'value': False})
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 remote-released event leaves a notification in local-visible instead of local-remounting.

Notification handoff to another surface is a bounded visual-notification workflow with mutable policy state {'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'}. Its default transition relation is {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}; 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 = {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'remote-visible', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}
    data = json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})) if payload is None else {**json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('remote-accepted','remote-painted','remote-released','remote-rejected','remote-paint-failed'):
                if arg.get('transfer',data['transfer']) != data['transfer'] or arg.get('owner',data['remote_owner']) != data['remote_owner']: event = 'unknown-event'
            if event == 'remote-painted': data['remote'] = True
            if event == 'remote-released': data['remote'] = False
            state = table.get((state, event), state)
            if state == 'remote-visible': data['local'] = False
            if state in ('local-visible','handoff-error'): data['local'] = True
            if state == 'local-hidden': data['local'] = False
    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('local-visible / send-to-other-surface', solve('local-visible', [('send-to-other-surface', N)], N), 'handoff-pending')
check('handoff-pending / remote-accepted', solve('handoff-pending', [('remote-accepted', N)], N), 'remote-mounting')
check('remote-mounting / remote-painted', solve('remote-mounting', [('remote-painted', N)], N), 'remote-visible')
check('remote-mounting / remote-paint-failed', solve('remote-mounting', [('remote-paint-failed', N)], N), 'handoff-error')
check('handoff-pending / remote-rejected', solve('handoff-pending', [('remote-rejected', N)], N), 'handoff-error')
check('handoff-error / retry-handoff', solve('handoff-error', [('retry-handoff', N)], N), 'handoff-pending')
check('remote-visible / bring-back', solve('remote-visible', [('bring-back', N)], N), 'recall-pending')
check('recall-pending / remote-released', solve('recall-pending', [('remote-released', N)], N), 'local-remounting')
check('local-remounting / local-painted', solve('local-remounting', [('local-painted', N)], N), 'local-visible')
check('handoff-pending / cancel-handoff', solve('handoff-pending', [('cancel-handoff', N)], N), 'cancel-pending')
check('older notification incarnation', solve('local-visible', [('send-to-other-surface', N - 1)], N), 'local-visible')
check('future notification incarnation', solve('local-visible', [('send-to-other-surface', N + 1)], N), 'local-visible')
check('unknown event is inert', solve('local-visible', [('unknown-event', N)], N), 'local-visible')
check('empty delivery batch', solve('local-visible', [], N), 'local-visible')
check('N stale deliveries before current delivery', solve('local-visible', [('send-to-other-surface', N - 1)] * N + [('send-to-other-surface', N)], N), 'handoff-pending')
check('trace send-to-other-surface then remote-accepted', solve('local-visible', [('send-to-other-surface', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace send-to-other-surface then remote-rejected', solve('local-visible', [('send-to-other-surface', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace send-to-other-surface then cancel-handoff', solve('local-visible', [('send-to-other-surface', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace remote-accepted then remote-painted', solve('handoff-pending', [('remote-accepted', N), ('remote-painted', N)], N), 'remote-visible')
check('trace remote-accepted then remote-paint-failed', solve('handoff-pending', [('remote-accepted', N), ('remote-paint-failed', N)], N), 'handoff-error')
check('trace remote-painted then bring-back', solve('remote-mounting', [('remote-painted', N), ('bring-back', N)], N), 'recall-pending')
check('trace remote-paint-failed then retry-handoff', solve('remote-mounting', [('remote-paint-failed', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace remote-rejected then retry-handoff', solve('handoff-pending', [('remote-rejected', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace retry-handoff then remote-accepted', solve('handoff-error', [('retry-handoff', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace retry-handoff then remote-rejected', solve('handoff-error', [('retry-handoff', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace retry-handoff then cancel-handoff', solve('handoff-error', [('retry-handoff', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace bring-back then remote-released', solve('remote-visible', [('bring-back', N), ('remote-released', N)], N), 'local-remounting')
check('trace remote-released then local-painted', solve('recall-pending', [('remote-released', N), ('local-painted', N)], N), 'local-visible')
check('trace local-painted then send-to-other-surface', solve('local-remounting', [('local-painted', N), ('send-to-other-surface', N)], N), 'handoff-pending')
check('domain state regression 1: local', solve('handoff-pending', [('remote-accepted', N, {'transfer': 3})], N, {}, 'local'), {'phase': 'handoff-pending', 'value': True})
check('domain state regression 2: remote', solve('remote-mounting', [('remote-painted', N, {'owner': 'phone'})], N, {}, 'remote'), {'phase': 'remote-mounting', 'value': False})
check('domain state regression 3: local', solve('remote-mounting', [('remote-painted', N, {})], N, {}, 'local'), {'phase': 'remote-visible', 'value': False})
check('domain state regression 4: local', solve('remote-mounting', [('remote-paint-failed', N, {})], N, {}, 'local'), {'phase': 'handoff-error', 'value': True})
check('domain state regression 5: remote', solve('recall-pending', [('remote-released', N, {})], N, {'local': False, 'remote': True}, 'remote'), {'phase': 'local-remounting', 'value': False})
check('domain state regression 6: local', solve('local-remounting', [('local-painted', N, {})], N, {'local': False, 'remote': False}, 'local'), {'phase': 'local-visible', 'value': True})
check('domain state regression 7: remote', solve('local-visible', [('send-to-other-surface', N, {}), ('remote-accepted', N, {}), ('remote-painted', N, {}), ('bring-back', N, {}), ('remote-released', N, {}), ('local-painted', N, {})], N, {}, 'remote'), {'phase': 'local-visible', 'value': False})
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 = {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'local-hidden', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}
    data = json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})) if payload is None else {**json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('remote-accepted','remote-painted','remote-released','remote-rejected','remote-paint-failed'):
                if arg.get('transfer',data['transfer']) != data['transfer'] or arg.get('owner',data['remote_owner']) != data['remote_owner']: event = 'unknown-event'
            if event == 'remote-painted': data['remote'] = True
            if event == 'remote-released': data['remote'] = False
            state = table.get((state, event), state)
            if state == 'remote-visible': data['local'] = False
            if state in ('local-visible','handoff-error'): data['local'] = True
            if state == 'local-hidden': data['local'] = False
    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('local-visible / send-to-other-surface', solve('local-visible', [('send-to-other-surface', N)], N), 'handoff-pending')
check('handoff-pending / remote-accepted', solve('handoff-pending', [('remote-accepted', N)], N), 'remote-mounting')
check('remote-mounting / remote-painted', solve('remote-mounting', [('remote-painted', N)], N), 'remote-visible')
check('remote-mounting / remote-paint-failed', solve('remote-mounting', [('remote-paint-failed', N)], N), 'handoff-error')
check('handoff-pending / remote-rejected', solve('handoff-pending', [('remote-rejected', N)], N), 'handoff-error')
check('handoff-error / retry-handoff', solve('handoff-error', [('retry-handoff', N)], N), 'handoff-pending')
check('remote-visible / bring-back', solve('remote-visible', [('bring-back', N)], N), 'recall-pending')
check('recall-pending / remote-released', solve('recall-pending', [('remote-released', N)], N), 'local-remounting')
check('local-remounting / local-painted', solve('local-remounting', [('local-painted', N)], N), 'local-visible')
check('handoff-pending / cancel-handoff', solve('handoff-pending', [('cancel-handoff', N)], N), 'cancel-pending')
check('older notification incarnation', solve('local-visible', [('send-to-other-surface', N - 1)], N), 'local-visible')
check('future notification incarnation', solve('local-visible', [('send-to-other-surface', N + 1)], N), 'local-visible')
check('unknown event is inert', solve('local-visible', [('unknown-event', N)], N), 'local-visible')
check('empty delivery batch', solve('local-visible', [], N), 'local-visible')
check('N stale deliveries before current delivery', solve('local-visible', [('send-to-other-surface', N - 1)] * N + [('send-to-other-surface', N)], N), 'handoff-pending')
check('trace send-to-other-surface then remote-accepted', solve('local-visible', [('send-to-other-surface', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace send-to-other-surface then remote-rejected', solve('local-visible', [('send-to-other-surface', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace send-to-other-surface then cancel-handoff', solve('local-visible', [('send-to-other-surface', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace remote-accepted then remote-painted', solve('handoff-pending', [('remote-accepted', N), ('remote-painted', N)], N), 'remote-visible')
check('trace remote-accepted then remote-paint-failed', solve('handoff-pending', [('remote-accepted', N), ('remote-paint-failed', N)], N), 'handoff-error')
check('trace remote-painted then bring-back', solve('remote-mounting', [('remote-painted', N), ('bring-back', N)], N), 'recall-pending')
check('trace remote-paint-failed then retry-handoff', solve('remote-mounting', [('remote-paint-failed', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace remote-rejected then retry-handoff', solve('handoff-pending', [('remote-rejected', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace retry-handoff then remote-accepted', solve('handoff-error', [('retry-handoff', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace retry-handoff then remote-rejected', solve('handoff-error', [('retry-handoff', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace retry-handoff then cancel-handoff', solve('handoff-error', [('retry-handoff', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace bring-back then remote-released', solve('remote-visible', [('bring-back', N), ('remote-released', N)], N), 'local-remounting')
check('trace remote-released then local-painted', solve('recall-pending', [('remote-released', N), ('local-painted', N)], N), 'local-visible')
check('trace local-painted then send-to-other-surface', solve('local-remounting', [('local-painted', N), ('send-to-other-surface', N)], N), 'handoff-pending')
check('domain state regression 1: local', solve('handoff-pending', [('remote-accepted', N, {'transfer': 3})], N, {}, 'local'), {'phase': 'handoff-pending', 'value': True})
check('domain state regression 2: remote', solve('remote-mounting', [('remote-painted', N, {'owner': 'phone'})], N, {}, 'remote'), {'phase': 'remote-mounting', 'value': False})
check('domain state regression 3: local', solve('remote-mounting', [('remote-painted', N, {})], N, {}, 'local'), {'phase': 'remote-visible', 'value': False})
check('domain state regression 4: local', solve('remote-mounting', [('remote-paint-failed', N, {})], N, {}, 'local'), {'phase': 'handoff-error', 'value': True})
check('domain state regression 5: remote', solve('recall-pending', [('remote-released', N, {})], N, {'local': False, 'remote': True}, 'remote'), {'phase': 'local-remounting', 'value': False})
check('domain state regression 6: local', solve('local-remounting', [('local-painted', N, {})], N, {'local': False, 'remote': False}, 'local'), {'phase': 'local-visible', 'value': True})
check('domain state regression 7: remote', solve('local-visible', [('send-to-other-surface', N, {}), ('remote-accepted', N, {}), ('remote-painted', N, {}), ('bring-back', N, {}), ('remote-released', N, {}), ('local-painted', N, {})], N, {}, 'remote'), {'phase': 'local-visible', 'value': False})
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 local-painted event leaves a notification in remote-visible instead of local-visible.

Notification handoff to another surface is a bounded visual-notification workflow with mutable policy state {'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'}. Its default transition relation is {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}; 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 = {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'local-visible'}
    data = json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})) if payload is None else {**json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('remote-accepted','remote-painted','remote-released','remote-rejected','remote-paint-failed'):
                if arg.get('transfer',data['transfer']) != data['transfer'] or arg.get('owner',data['remote_owner']) != data['remote_owner']: event = 'unknown-event'
            if event == 'remote-painted': data['remote'] = True
            if event == 'remote-released': data['remote'] = False
            state = table.get((state, event), state)
            if state == 'remote-visible': data['local'] = False
            if state in ('local-visible','handoff-error'): data['local'] = True
            if state == 'local-hidden': data['local'] = False
    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('local-visible / send-to-other-surface', solve('local-visible', [('send-to-other-surface', N)], N), 'handoff-pending')
check('handoff-pending / remote-accepted', solve('handoff-pending', [('remote-accepted', N)], N), 'remote-mounting')
check('remote-mounting / remote-painted', solve('remote-mounting', [('remote-painted', N)], N), 'remote-visible')
check('remote-mounting / remote-paint-failed', solve('remote-mounting', [('remote-paint-failed', N)], N), 'handoff-error')
check('handoff-pending / remote-rejected', solve('handoff-pending', [('remote-rejected', N)], N), 'handoff-error')
check('handoff-error / retry-handoff', solve('handoff-error', [('retry-handoff', N)], N), 'handoff-pending')
check('remote-visible / bring-back', solve('remote-visible', [('bring-back', N)], N), 'recall-pending')
check('recall-pending / remote-released', solve('recall-pending', [('remote-released', N)], N), 'local-remounting')
check('local-remounting / local-painted', solve('local-remounting', [('local-painted', N)], N), 'local-visible')
check('handoff-pending / cancel-handoff', solve('handoff-pending', [('cancel-handoff', N)], N), 'cancel-pending')
check('older notification incarnation', solve('local-visible', [('send-to-other-surface', N - 1)], N), 'local-visible')
check('future notification incarnation', solve('local-visible', [('send-to-other-surface', N + 1)], N), 'local-visible')
check('unknown event is inert', solve('local-visible', [('unknown-event', N)], N), 'local-visible')
check('empty delivery batch', solve('local-visible', [], N), 'local-visible')
check('N stale deliveries before current delivery', solve('local-visible', [('send-to-other-surface', N - 1)] * N + [('send-to-other-surface', N)], N), 'handoff-pending')
check('trace send-to-other-surface then remote-accepted', solve('local-visible', [('send-to-other-surface', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace send-to-other-surface then remote-rejected', solve('local-visible', [('send-to-other-surface', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace send-to-other-surface then cancel-handoff', solve('local-visible', [('send-to-other-surface', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace remote-accepted then remote-painted', solve('handoff-pending', [('remote-accepted', N), ('remote-painted', N)], N), 'remote-visible')
check('trace remote-accepted then remote-paint-failed', solve('handoff-pending', [('remote-accepted', N), ('remote-paint-failed', N)], N), 'handoff-error')
check('trace remote-painted then bring-back', solve('remote-mounting', [('remote-painted', N), ('bring-back', N)], N), 'recall-pending')
check('trace remote-paint-failed then retry-handoff', solve('remote-mounting', [('remote-paint-failed', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace remote-rejected then retry-handoff', solve('handoff-pending', [('remote-rejected', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace retry-handoff then remote-accepted', solve('handoff-error', [('retry-handoff', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace retry-handoff then remote-rejected', solve('handoff-error', [('retry-handoff', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace retry-handoff then cancel-handoff', solve('handoff-error', [('retry-handoff', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace bring-back then remote-released', solve('remote-visible', [('bring-back', N), ('remote-released', N)], N), 'local-remounting')
check('trace remote-released then local-painted', solve('recall-pending', [('remote-released', N), ('local-painted', N)], N), 'local-visible')
check('trace local-painted then send-to-other-surface', solve('local-remounting', [('local-painted', N), ('send-to-other-surface', N)], N), 'handoff-pending')
check('domain state regression 1: local', solve('handoff-pending', [('remote-accepted', N, {'transfer': 3})], N, {}, 'local'), {'phase': 'handoff-pending', 'value': True})
check('domain state regression 2: remote', solve('remote-mounting', [('remote-painted', N, {'owner': 'phone'})], N, {}, 'remote'), {'phase': 'remote-mounting', 'value': False})
check('domain state regression 3: local', solve('remote-mounting', [('remote-painted', N, {})], N, {}, 'local'), {'phase': 'remote-visible', 'value': False})
check('domain state regression 4: local', solve('remote-mounting', [('remote-paint-failed', N, {})], N, {}, 'local'), {'phase': 'handoff-error', 'value': True})
check('domain state regression 5: remote', solve('recall-pending', [('remote-released', N, {})], N, {'local': False, 'remote': True}, 'remote'), {'phase': 'local-remounting', 'value': False})
check('domain state regression 6: local', solve('local-remounting', [('local-painted', N, {})], N, {'local': False, 'remote': False}, 'local'), {'phase': 'local-visible', 'value': True})
check('domain state regression 7: remote', solve('local-visible', [('send-to-other-surface', N, {}), ('remote-accepted', N, {}), ('remote-painted', N, {}), ('bring-back', N, {}), ('remote-released', N, {}), ('local-painted', N, {})], N, {}, 'remote'), {'phase': 'local-visible', 'value': False})
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 = {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'local-hidden'}
    data = json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})) if payload is None else {**json.loads(json.dumps({'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'})), **json.loads(json.dumps(payload))}
    state = initial
    for delivery in events:
        event, event_generation = delivery[:2]
        arg = delivery[2] if len(delivery) > 2 else {}
        if event_generation == generation:
            previous = state
            if event in ('remote-accepted','remote-painted','remote-released','remote-rejected','remote-paint-failed'):
                if arg.get('transfer',data['transfer']) != data['transfer'] or arg.get('owner',data['remote_owner']) != data['remote_owner']: event = 'unknown-event'
            if event == 'remote-painted': data['remote'] = True
            if event == 'remote-released': data['remote'] = False
            state = table.get((state, event), state)
            if state == 'remote-visible': data['local'] = False
            if state in ('local-visible','handoff-error'): data['local'] = True
            if state == 'local-hidden': data['local'] = False
    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('local-visible / send-to-other-surface', solve('local-visible', [('send-to-other-surface', N)], N), 'handoff-pending')
check('handoff-pending / remote-accepted', solve('handoff-pending', [('remote-accepted', N)], N), 'remote-mounting')
check('remote-mounting / remote-painted', solve('remote-mounting', [('remote-painted', N)], N), 'remote-visible')
check('remote-mounting / remote-paint-failed', solve('remote-mounting', [('remote-paint-failed', N)], N), 'handoff-error')
check('handoff-pending / remote-rejected', solve('handoff-pending', [('remote-rejected', N)], N), 'handoff-error')
check('handoff-error / retry-handoff', solve('handoff-error', [('retry-handoff', N)], N), 'handoff-pending')
check('remote-visible / bring-back', solve('remote-visible', [('bring-back', N)], N), 'recall-pending')
check('recall-pending / remote-released', solve('recall-pending', [('remote-released', N)], N), 'local-remounting')
check('local-remounting / local-painted', solve('local-remounting', [('local-painted', N)], N), 'local-visible')
check('handoff-pending / cancel-handoff', solve('handoff-pending', [('cancel-handoff', N)], N), 'cancel-pending')
check('older notification incarnation', solve('local-visible', [('send-to-other-surface', N - 1)], N), 'local-visible')
check('future notification incarnation', solve('local-visible', [('send-to-other-surface', N + 1)], N), 'local-visible')
check('unknown event is inert', solve('local-visible', [('unknown-event', N)], N), 'local-visible')
check('empty delivery batch', solve('local-visible', [], N), 'local-visible')
check('N stale deliveries before current delivery', solve('local-visible', [('send-to-other-surface', N - 1)] * N + [('send-to-other-surface', N)], N), 'handoff-pending')
check('trace send-to-other-surface then remote-accepted', solve('local-visible', [('send-to-other-surface', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace send-to-other-surface then remote-rejected', solve('local-visible', [('send-to-other-surface', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace send-to-other-surface then cancel-handoff', solve('local-visible', [('send-to-other-surface', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace remote-accepted then remote-painted', solve('handoff-pending', [('remote-accepted', N), ('remote-painted', N)], N), 'remote-visible')
check('trace remote-accepted then remote-paint-failed', solve('handoff-pending', [('remote-accepted', N), ('remote-paint-failed', N)], N), 'handoff-error')
check('trace remote-painted then bring-back', solve('remote-mounting', [('remote-painted', N), ('bring-back', N)], N), 'recall-pending')
check('trace remote-paint-failed then retry-handoff', solve('remote-mounting', [('remote-paint-failed', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace remote-rejected then retry-handoff', solve('handoff-pending', [('remote-rejected', N), ('retry-handoff', N)], N), 'handoff-pending')
check('trace retry-handoff then remote-accepted', solve('handoff-error', [('retry-handoff', N), ('remote-accepted', N)], N), 'remote-mounting')
check('trace retry-handoff then remote-rejected', solve('handoff-error', [('retry-handoff', N), ('remote-rejected', N)], N), 'handoff-error')
check('trace retry-handoff then cancel-handoff', solve('handoff-error', [('retry-handoff', N), ('cancel-handoff', N)], N), 'cancel-pending')
check('trace bring-back then remote-released', solve('remote-visible', [('bring-back', N), ('remote-released', N)], N), 'local-remounting')
check('trace remote-released then local-painted', solve('recall-pending', [('remote-released', N), ('local-painted', N)], N), 'local-visible')
check('trace local-painted then send-to-other-surface', solve('local-remounting', [('local-painted', N), ('send-to-other-surface', N)], N), 'handoff-pending')
check('domain state regression 1: local', solve('handoff-pending', [('remote-accepted', N, {'transfer': 3})], N, {}, 'local'), {'phase': 'handoff-pending', 'value': True})
check('domain state regression 2: remote', solve('remote-mounting', [('remote-painted', N, {'owner': 'phone'})], N, {}, 'remote'), {'phase': 'remote-mounting', 'value': False})
check('domain state regression 3: local', solve('remote-mounting', [('remote-painted', N, {})], N, {}, 'local'), {'phase': 'remote-visible', 'value': False})
check('domain state regression 4: local', solve('remote-mounting', [('remote-paint-failed', N, {})], N, {}, 'local'), {'phase': 'handoff-error', 'value': True})
check('domain state regression 5: remote', solve('recall-pending', [('remote-released', N, {})], N, {'local': False, 'remote': True}, 'remote'), {'phase': 'local-remounting', 'value': False})
check('domain state regression 6: local', solve('local-remounting', [('local-painted', N, {})], N, {'local': False, 'remote': False}, 'local'), {'phase': 'local-visible', 'value': True})
check('domain state regression 7: remote', solve('local-visible', [('send-to-other-surface', N, {}), ('remote-accepted', N, {}), ('remote-painted', N, {}), ('bring-back', N, {}), ('remote-released', N, {}), ('local-painted', N, {})], N, {}, 'remote'), {'phase': 'local-visible', 'value': False})
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 cancel-handoff event leaves a notification in local-visible instead of cancel-pending.

Notification handoff to another surface is a bounded visual-notification workflow with mutable policy state {'transfer': 4, 'local': True, 'remote': False, 'remote_owner': 'tablet'}. Its default transition relation is {('local-visible', 'send-to-other-surface'): 'handoff-pending', ('handoff-pending', 'remote-accepted'): 'remote-mounting', ('remote-mounting', 'remote-painted'): 'remote-visible', ('remote-mounting', 'remote-paint-failed'): 'handoff-error', ('handoff-pending', 'remote-rejected'): 'handoff-error', ('handoff-error', 'retry-handoff'): 'handoff-pending', ('remote-visible', 'bring-back'): 'recall-pending', ('recall-pending', 'remote-released'): 'local-remounting', ('local-remounting', 'local-painted'): 'local-visible', ('handoff-pending', 'cancel-handoff'): 'cancel-pending'}; 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


prompt:
The tab workspace reports an incorrect partition boundary.

Insert an unpinned document after all pins, retaining pinned prefix order and active document identity.

split: open-access


prompt:
The tab workspace reports an incorrect insertion slot.

Insert an unpinned document after all pins, retaining pinned prefix order and active document identity.

split: open-access


prompt:
The tab workspace reports an incorrect pinned order.

Insert an unpinned document after all pins, retaining pinned prefix order and active document identity.

split: open-access


prompt:
The tab workspace reports an incorrect unpinned retention.

Insert an unpinned document after all pins, retaining pinned prefix order and active document identity.

split: open-access


prompt:
The tab workspace reports an incorrect active identity.

Insert an unpinned document after all pins, retaining pinned prefix order and active document identity.

split: open-access


prompt:
The tab workspace reports an incorrect new tab pin status.

Insert an unpinned document after all pins, retaining pinned prefix order and active document identity.

split: open-access


prompt:
The tab workspace reports an incorrect close eligibility.

Close requested clean unpinned tabs atomically; retain dirty and pinned tabs, select most recent surviving tab and preserve surviving history.

split: open-access


prompt:
The tab workspace reports an incorrect dirty prompts.

Close requested clean unpinned tabs atomically; retain dirty and pinned tabs, select most recent surviving tab and preserve surviving history.

split: open-access


prompt:
The tab workspace reports an incorrect pinned veto.

Close requested clean unpinned tabs atomically; retain dirty and pinned tabs, select most recent surviving tab and preserve surviving history.

split: open-access


prompt:
The tab workspace reports an incorrect survivor order.

Close requested clean unpinned tabs atomically; retain dirty and pinned tabs, select most recent surviving tab and preserve surviving history.

split: open-access


prompt:
The tab workspace reports an incorrect mru successor.

Close requested clean unpinned tabs atomically; retain dirty and pinned tabs, select most recent surviving tab and preserve surviving history.

split: open-access


prompt:
The tab workspace reports an incorrect history pruning.

Close requested clean unpinned tabs atomically; retain dirty and pinned tabs, select most recent surviving tab and preserve surviving history.

split: open-access


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

N = 1
observations = []
def solve(x):
    r0 = x['preview'] is not None
    r1 = x['incoming']
    r2 = 0 if x['incoming']!=x['preview'] else x['scroll']
    r3 = 'durable' if x['promote'] else 'preview'
    r4 = x['dirty'] or x['pinned']
    r5 = x['slot'] if x['preview'] is not None and not x['dirty'] and not x['pinned'] else x['slot']+1
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 70, 'promote': True}, [True, 'new', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': True, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 70, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': True, 'incoming': 'new', 'slot': 2, 'scroll': 70, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 70, 'promote': False}, [True, 'new', 0, 'preview', False, 2]), ({'preview': None, 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 70, 'promote': True}, [False, 'new', 0, 'durable', False, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 0, 'promote': True}, [True, 'old', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 70, 'promote': True}, [True, 'old', 70, 'durable', False, 2])], 2: [({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 140, 'promote': True}, [True, 'new', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': True, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 140, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': True, 'incoming': 'new', 'slot': 2, 'scroll': 140, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 140, 'promote': False}, [True, 'new', 0, 'preview', False, 2]), ({'preview': None, 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 140, 'promote': True}, [False, 'new', 0, 'durable', False, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 0, 'promote': True}, [True, 'old', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 140, 'promote': True}, [True, 'old', 140, 'durable', False, 2])], 3: [({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 210, 'promote': True}, [True, 'new', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': True, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 210, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': True, 'incoming': 'new', 'slot': 2, 'scroll': 210, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 210, 'promote': False}, [True, 'new', 0, 'preview', False, 2]), ({'preview': None, 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 210, 'promote': True}, [False, 'new', 0, 'durable', False, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 0, 'promote': True}, [True, 'old', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 210, 'promote': True}, [True, 'old', 210, 'durable', False, 2])], 4: [({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 280, 'promote': True}, [True, 'new', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': True, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 280, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': True, 'incoming': 'new', 'slot': 2, 'scroll': 280, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 280, 'promote': False}, [True, 'new', 0, 'preview', False, 2]), ({'preview': None, 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 280, 'promote': True}, [False, 'new', 0, 'durable', False, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 0, 'promote': True}, [True, 'old', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 280, 'promote': True}, [True, 'old', 280, 'durable', False, 2])], 5: [({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 350, 'promote': True}, [True, 'new', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': True, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 350, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': True, 'incoming': 'new', 'slot': 2, 'scroll': 350, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 350, 'promote': False}, [True, 'new', 0, 'preview', False, 2]), ({'preview': None, 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 350, 'promote': True}, [False, 'new', 0, 'durable', False, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 0, 'promote': True}, [True, 'old', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 350, 'promote': True}, [True, 'old', 350, 'durable', False, 2])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    r0 = not x['dirty']
    r1 = x['incoming']
    r2 = 0 if x['incoming']!=x['preview'] else x['scroll']
    r3 = 'durable' if x['promote'] else 'preview'
    r4 = x['dirty'] or x['pinned']
    r5 = x['slot'] if x['preview'] is not None and not x['dirty'] and not x['pinned'] else x['slot']+1
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 70, 'promote': True}, [True, 'new', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': True, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 70, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': True, 'incoming': 'new', 'slot': 2, 'scroll': 70, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 70, 'promote': False}, [True, 'new', 0, 'preview', False, 2]), ({'preview': None, 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 70, 'promote': True}, [False, 'new', 0, 'durable', False, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 0, 'promote': True}, [True, 'old', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 70, 'promote': True}, [True, 'old', 70, 'durable', False, 2])], 2: [({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 140, 'promote': True}, [True, 'new', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': True, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 140, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': True, 'incoming': 'new', 'slot': 2, 'scroll': 140, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 140, 'promote': False}, [True, 'new', 0, 'preview', False, 2]), ({'preview': None, 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 140, 'promote': True}, [False, 'new', 0, 'durable', False, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 0, 'promote': True}, [True, 'old', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 140, 'promote': True}, [True, 'old', 140, 'durable', False, 2])], 3: [({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 210, 'promote': True}, [True, 'new', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': True, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 210, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': True, 'incoming': 'new', 'slot': 2, 'scroll': 210, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 210, 'promote': False}, [True, 'new', 0, 'preview', False, 2]), ({'preview': None, 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 210, 'promote': True}, [False, 'new', 0, 'durable', False, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 0, 'promote': True}, [True, 'old', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 210, 'promote': True}, [True, 'old', 210, 'durable', False, 2])], 4: [({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 280, 'promote': True}, [True, 'new', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': True, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 280, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': True, 'incoming': 'new', 'slot': 2, 'scroll': 280, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 280, 'promote': False}, [True, 'new', 0, 'preview', False, 2]), ({'preview': None, 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 280, 'promote': True}, [False, 'new', 0, 'durable', False, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 0, 'promote': True}, [True, 'old', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 280, 'promote': True}, [True, 'old', 280, 'durable', False, 2])], 5: [({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 350, 'promote': True}, [True, 'new', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': True, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 350, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': True, 'incoming': 'new', 'slot': 2, 'scroll': 350, 'promote': True}, [False, 'new', 0, 'durable', True, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 350, 'promote': False}, [True, 'new', 0, 'preview', False, 2]), ({'preview': None, 'dirty': False, 'pinned': False, 'incoming': 'new', 'slot': 2, 'scroll': 350, 'promote': True}, [False, 'new', 0, 'durable', False, 3]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 0, 'promote': True}, [True, 'old', 0, 'durable', False, 2]), ({'preview': 'old', 'dirty': False, 'pinned': False, 'incoming': 'old', 'slot': 2, 'scroll': 350, 'promote': True}, [True, 'old', 350, 'durable', False, 2])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The tab workspace reports an incorrect reusable preview.

A preview can replace only a clean unpinned preview. Reusing the view retains its slot but replaces document state; promotion makes it durable.

split: open-access