broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'semantic':
        return {'command':p['row'],'arguments':p['arguments']}
    if action == 'failed':
        return p['macro'] if not p['success'] else p['macro']+[p['entry']]
    if action == 'private-args':
        return {k:v for k,v in p['args'].items() if k not in p['private']}
    if action == 'playback-order':
        return p['steps']
    if action == 'recording-playback':
        return p['recording'] and not p['replaying']
    if action == 'typed-parameters':
        return p['args']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('semantic contract', solve('semantic', {'command':'resize','arguments':{'size':N},'row':'row-7','label':'Resize'}), {'command':'resize','arguments':{'size':N}})
check('failed contract', solve('failed', {'macro':[N],'entry':N+1,'success':False}), [N])
check('private-args contract', solve('private-args', {'args':{'size':N,'document_token':'private'},'private':['document_token']}), {'size':N})
check('playback-order contract', solve('playback-order', {'steps':['create','write'+str(N),'close']}), ['create','write'+str(N),'close'])
check('recording-playback contract', solve('recording-playback', {'recording':True,'replaying':True,'step':N}), False)
check('typed-parameters contract', solve('typed-parameters', {'args':{'count':N+1,'enabled':False}}), {'count':N+1,'enabled':False})
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'semantic':
        return {'command':p['command'],'arguments':p['label']}
    if action == 'failed':
        return p['macro'] if not p['success'] else p['macro']+[p['entry']]
    if action == 'private-args':
        return {k:v for k,v in p['args'].items() if k not in p['private']}
    if action == 'playback-order':
        return p['steps']
    if action == 'recording-playback':
        return p['recording'] and not p['replaying']
    if action == 'typed-parameters':
        return p['args']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('semantic contract', solve('semantic', {'command':'resize','arguments':{'size':N},'row':'row-7','label':'Resize'}), {'command':'resize','arguments':{'size':N}})
check('failed contract', solve('failed', {'macro':[N],'entry':N+1,'success':False}), [N])
check('private-args contract', solve('private-args', {'args':{'size':N,'document_token':'private'},'private':['document_token']}), {'size':N})
check('playback-order contract', solve('playback-order', {'steps':['create','write'+str(N),'close']}), ['create','write'+str(N),'close'])
check('recording-playback contract', solve('recording-playback', {'recording':True,'replaying':True,'step':N}), False)
check('typed-parameters contract', solve('typed-parameters', {'args':{'count':N+1,'enabled':False}}), {'count':N+1,'enabled':False})
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Menu macro records a transient row ID instead of the semantic command.

Menu command macros record successful semantic commands, omit private context data, preserve execution order and retain typed parameter bindings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'semantic':
        return {'command':p['command'],'arguments':p['arguments']}
    if action == 'failed':
        return p['macro']+[p['entry']]
    if action == 'private-args':
        return {k:v for k,v in p['args'].items() if k not in p['private']}
    if action == 'playback-order':
        return p['steps']
    if action == 'recording-playback':
        return p['recording'] and not p['replaying']
    if action == 'typed-parameters':
        return p['args']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('semantic contract', solve('semantic', {'command':'resize','arguments':{'size':N},'row':'row-7','label':'Resize'}), {'command':'resize','arguments':{'size':N}})
check('failed contract', solve('failed', {'macro':[N],'entry':N+1,'success':False}), [N])
check('private-args contract', solve('private-args', {'args':{'size':N,'document_token':'private'},'private':['document_token']}), {'size':N})
check('playback-order contract', solve('playback-order', {'steps':['create','write'+str(N),'close']}), ['create','write'+str(N),'close'])
check('recording-playback contract', solve('recording-playback', {'recording':True,'replaying':True,'step':N}), False)
check('typed-parameters contract', solve('typed-parameters', {'args':{'count':N+1,'enabled':False}}), {'count':N+1,'enabled':False})
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'semantic':
        return {'command':p['command'],'arguments':p['arguments']}
    if action == 'failed':
        return []
    if action == 'private-args':
        return {k:v for k,v in p['args'].items() if k not in p['private']}
    if action == 'playback-order':
        return p['steps']
    if action == 'recording-playback':
        return p['recording'] and not p['replaying']
    if action == 'typed-parameters':
        return p['args']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('semantic contract', solve('semantic', {'command':'resize','arguments':{'size':N},'row':'row-7','label':'Resize'}), {'command':'resize','arguments':{'size':N}})
check('failed contract', solve('failed', {'macro':[N],'entry':N+1,'success':False}), [N])
check('private-args contract', solve('private-args', {'args':{'size':N,'document_token':'private'},'private':['document_token']}), {'size':N})
check('playback-order contract', solve('playback-order', {'steps':['create','write'+str(N),'close']}), ['create','write'+str(N),'close'])
check('recording-playback contract', solve('recording-playback', {'recording':True,'replaying':True,'step':N}), False)
check('typed-parameters contract', solve('typed-parameters', {'args':{'count':N+1,'enabled':False}}), {'count':N+1,'enabled':False})
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Failed menu action is appended to command macro playback.

Menu command macros record successful semantic commands, omit private context data, preserve execution order and retain typed parameter bindings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'semantic':
        return {'command':p['command'],'arguments':p['arguments']}
    if action == 'failed':
        return p['macro'] if not p['success'] else p['macro']+[p['entry']]
    if action == 'private-args':
        return p['args']
    if action == 'playback-order':
        return p['steps']
    if action == 'recording-playback':
        return p['recording'] and not p['replaying']
    if action == 'typed-parameters':
        return p['args']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('semantic contract', solve('semantic', {'command':'resize','arguments':{'size':N},'row':'row-7','label':'Resize'}), {'command':'resize','arguments':{'size':N}})
check('failed contract', solve('failed', {'macro':[N],'entry':N+1,'success':False}), [N])
check('private-args contract', solve('private-args', {'args':{'size':N,'document_token':'private'},'private':['document_token']}), {'size':N})
check('playback-order contract', solve('playback-order', {'steps':['create','write'+str(N),'close']}), ['create','write'+str(N),'close'])
check('recording-playback contract', solve('recording-playback', {'recording':True,'replaying':True,'step':N}), False)
check('typed-parameters contract', solve('typed-parameters', {'args':{'count':N+1,'enabled':False}}), {'count':N+1,'enabled':False})
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'semantic':
        return {'command':p['command'],'arguments':p['arguments']}
    if action == 'failed':
        return p['macro'] if not p['success'] else p['macro']+[p['entry']]
    if action == 'private-args':
        return {}
    if action == 'playback-order':
        return p['steps']
    if action == 'recording-playback':
        return p['recording'] and not p['replaying']
    if action == 'typed-parameters':
        return p['args']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('semantic contract', solve('semantic', {'command':'resize','arguments':{'size':N},'row':'row-7','label':'Resize'}), {'command':'resize','arguments':{'size':N}})
check('failed contract', solve('failed', {'macro':[N],'entry':N+1,'success':False}), [N])
check('private-args contract', solve('private-args', {'args':{'size':N,'document_token':'private'},'private':['document_token']}), {'size':N})
check('playback-order contract', solve('playback-order', {'steps':['create','write'+str(N),'close']}), ['create','write'+str(N),'close'])
check('recording-playback contract', solve('recording-playback', {'recording':True,'replaying':True,'step':N}), False)
check('typed-parameters contract', solve('typed-parameters', {'args':{'count':N+1,'enabled':False}}), {'count':N+1,'enabled':False})
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Menu macro persists private invocation arguments.

Menu command macros record successful semantic commands, omit private context data, preserve execution order and retain typed parameter bindings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'semantic':
        return {'command':p['command'],'arguments':p['arguments']}
    if action == 'failed':
        return p['macro'] if not p['success'] else p['macro']+[p['entry']]
    if action == 'private-args':
        return {k:v for k,v in p['args'].items() if k not in p['private']}
    if action == 'playback-order':
        return list(reversed(p['steps']))
    if action == 'recording-playback':
        return p['recording'] and not p['replaying']
    if action == 'typed-parameters':
        return p['args']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('semantic contract', solve('semantic', {'command':'resize','arguments':{'size':N},'row':'row-7','label':'Resize'}), {'command':'resize','arguments':{'size':N}})
check('failed contract', solve('failed', {'macro':[N],'entry':N+1,'success':False}), [N])
check('private-args contract', solve('private-args', {'args':{'size':N,'document_token':'private'},'private':['document_token']}), {'size':N})
check('playback-order contract', solve('playback-order', {'steps':['create','write'+str(N),'close']}), ['create','write'+str(N),'close'])
check('recording-playback contract', solve('recording-playback', {'recording':True,'replaying':True,'step':N}), False)
check('typed-parameters contract', solve('typed-parameters', {'args':{'count':N+1,'enabled':False}}), {'count':N+1,'enabled':False})
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'semantic':
        return {'command':p['command'],'arguments':p['arguments']}
    if action == 'failed':
        return p['macro'] if not p['success'] else p['macro']+[p['entry']]
    if action == 'private-args':
        return {k:v for k,v in p['args'].items() if k not in p['private']}
    if action == 'playback-order':
        return sorted(p['steps'])
    if action == 'recording-playback':
        return p['recording'] and not p['replaying']
    if action == 'typed-parameters':
        return p['args']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('semantic contract', solve('semantic', {'command':'resize','arguments':{'size':N},'row':'row-7','label':'Resize'}), {'command':'resize','arguments':{'size':N}})
check('failed contract', solve('failed', {'macro':[N],'entry':N+1,'success':False}), [N])
check('private-args contract', solve('private-args', {'args':{'size':N,'document_token':'private'},'private':['document_token']}), {'size':N})
check('playback-order contract', solve('playback-order', {'steps':['create','write'+str(N),'close']}), ['create','write'+str(N),'close'])
check('recording-playback contract', solve('recording-playback', {'recording':True,'replaying':True,'step':N}), False)
check('typed-parameters contract', solve('typed-parameters', {'args':{'count':N+1,'enabled':False}}), {'count':N+1,'enabled':False})
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Menu macro playback reorders semantically dependent commands.

Menu command macros record successful semantic commands, omit private context data, preserve execution order and retain typed parameter bindings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'semantic':
        return {'command':p['command'],'arguments':p['arguments']}
    if action == 'failed':
        return p['macro'] if not p['success'] else p['macro']+[p['entry']]
    if action == 'private-args':
        return {k:v for k,v in p['args'].items() if k not in p['private']}
    if action == 'playback-order':
        return p['steps']
    if action == 'recording-playback':
        return p['recording']
    if action == 'typed-parameters':
        return p['args']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('semantic contract', solve('semantic', {'command':'resize','arguments':{'size':N},'row':'row-7','label':'Resize'}), {'command':'resize','arguments':{'size':N}})
check('failed contract', solve('failed', {'macro':[N],'entry':N+1,'success':False}), [N])
check('private-args contract', solve('private-args', {'args':{'size':N,'document_token':'private'},'private':['document_token']}), {'size':N})
check('playback-order contract', solve('playback-order', {'steps':['create','write'+str(N),'close']}), ['create','write'+str(N),'close'])
check('recording-playback contract', solve('recording-playback', {'recording':True,'replaying':True,'step':N}), False)
check('typed-parameters contract', solve('typed-parameters', {'args':{'count':N+1,'enabled':False}}), {'count':N+1,'enabled':False})
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'semantic':
        return {'command':p['command'],'arguments':p['arguments']}
    if action == 'failed':
        return p['macro'] if not p['success'] else p['macro']+[p['entry']]
    if action == 'private-args':
        return {k:v for k,v in p['args'].items() if k not in p['private']}
    if action == 'playback-order':
        return p['steps']
    if action == 'recording-playback':
        return p['recording'] or p['replaying']
    if action == 'typed-parameters':
        return p['args']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('semantic contract', solve('semantic', {'command':'resize','arguments':{'size':N},'row':'row-7','label':'Resize'}), {'command':'resize','arguments':{'size':N}})
check('failed contract', solve('failed', {'macro':[N],'entry':N+1,'success':False}), [N])
check('private-args contract', solve('private-args', {'args':{'size':N,'document_token':'private'},'private':['document_token']}), {'size':N})
check('playback-order contract', solve('playback-order', {'steps':['create','write'+str(N),'close']}), ['create','write'+str(N),'close'])
check('recording-playback contract', solve('recording-playback', {'recording':True,'replaying':True,'step':N}), False)
check('typed-parameters contract', solve('typed-parameters', {'args':{'count':N+1,'enabled':False}}), {'count':N+1,'enabled':False})
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Menu macro playback recursively records its own commands.

Menu command macros record successful semantic commands, omit private context data, preserve execution order and retain typed parameter bindings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'semantic':
        return {'command':p['command'],'arguments':p['arguments']}
    if action == 'failed':
        return p['macro'] if not p['success'] else p['macro']+[p['entry']]
    if action == 'private-args':
        return {k:v for k,v in p['args'].items() if k not in p['private']}
    if action == 'playback-order':
        return p['steps']
    if action == 'recording-playback':
        return p['recording'] and not p['replaying']
    if action == 'typed-parameters':
        return {k:str(v) for k,v in p['args'].items()}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('semantic contract', solve('semantic', {'command':'resize','arguments':{'size':N},'row':'row-7','label':'Resize'}), {'command':'resize','arguments':{'size':N}})
check('failed contract', solve('failed', {'macro':[N],'entry':N+1,'success':False}), [N])
check('private-args contract', solve('private-args', {'args':{'size':N,'document_token':'private'},'private':['document_token']}), {'size':N})
check('playback-order contract', solve('playback-order', {'steps':['create','write'+str(N),'close']}), ['create','write'+str(N),'close'])
check('recording-playback contract', solve('recording-playback', {'recording':True,'replaying':True,'step':N}), False)
check('typed-parameters contract', solve('typed-parameters', {'args':{'count':N+1,'enabled':False}}), {'count':N+1,'enabled':False})
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'semantic':
        return {'command':p['command'],'arguments':p['arguments']}
    if action == 'failed':
        return p['macro'] if not p['success'] else p['macro']+[p['entry']]
    if action == 'private-args':
        return {k:v for k,v in p['args'].items() if k not in p['private']}
    if action == 'playback-order':
        return p['steps']
    if action == 'recording-playback':
        return p['recording'] and not p['replaying']
    if action == 'typed-parameters':
        return {k:bool(v) for k,v in p['args'].items()}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('semantic contract', solve('semantic', {'command':'resize','arguments':{'size':N},'row':'row-7','label':'Resize'}), {'command':'resize','arguments':{'size':N}})
check('failed contract', solve('failed', {'macro':[N],'entry':N+1,'success':False}), [N])
check('private-args contract', solve('private-args', {'args':{'size':N,'document_token':'private'},'private':['document_token']}), {'size':N})
check('playback-order contract', solve('playback-order', {'steps':['create','write'+str(N),'close']}), ['create','write'+str(N),'close'])
check('recording-playback contract', solve('recording-playback', {'recording':True,'replaying':True,'step':N}), False)
check('typed-parameters contract', solve('typed-parameters', {'args':{'count':N+1,'enabled':False}}), {'count':N+1,'enabled':False})
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Menu macro stringifies typed command parameters.

Menu command macros record successful semantic commands, omit private context data, preserve execution order and retain typed parameter bindings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'base':
        return p['current_preview']+p['delta']
    if action == 'cancel':
        return p['base']
    if action == 'commit-once':
        return p['base']+p['delta']
    if action == 'owner-cleanup':
        return [x for x in p['overlays'] if x['menu']!=p['menu']]
    if action == 'supported':
        return p['previewable'] and p['reversible']
    if action == 'exit-mode':
        return 'commit' if p['reason']=='execute' else 'restore'
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('base contract', solve('base', {'base':N,'current_preview':N+5,'delta':2}), N+2)
check('cancel contract', solve('cancel', {'base':N,'current':N+3}), N)
check('commit-once contract', solve('commit-once', {'base':N,'preview':N+2,'delta':2}), N+2)
check('owner-cleanup contract', solve('owner-cleanup', {'overlays':[{'menu':'a','id':N},{'menu':'b','id':N+1}],'menu':'a'}), [{'menu':'b','id':N+1}])
check('supported contract', solve('supported', {'previewable':True,'reversible':False,'command':N}), False)
check('exit-mode contract', solve('exit-mode', {'reason':'leave','owner':N}), 'restore')
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'base':
        return p['delta']
    if action == 'cancel':
        return p['base']
    if action == 'commit-once':
        return p['base']+p['delta']
    if action == 'owner-cleanup':
        return [x for x in p['overlays'] if x['menu']!=p['menu']]
    if action == 'supported':
        return p['previewable'] and p['reversible']
    if action == 'exit-mode':
        return 'commit' if p['reason']=='execute' else 'restore'
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('base contract', solve('base', {'base':N,'current_preview':N+5,'delta':2}), N+2)
check('cancel contract', solve('cancel', {'base':N,'current':N+3}), N)
check('commit-once contract', solve('commit-once', {'base':N,'preview':N+2,'delta':2}), N+2)
check('owner-cleanup contract', solve('owner-cleanup', {'overlays':[{'menu':'a','id':N},{'menu':'b','id':N+1}],'menu':'a'}), [{'menu':'b','id':N+1}])
check('supported contract', solve('supported', {'previewable':True,'reversible':False,'command':N}), False)
check('exit-mode contract', solve('exit-mode', {'reason':'leave','owner':N}), 'restore')
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Menu preview accumulates on the previous preview instead of base state.

Hover previews are provisional document overlays; changing preview restores the base, commit applies the actual command once and cancellation removes only the menu-owned preview.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'base':
        return p['base']+p['delta']
    if action == 'cancel':
        return p['current']
    if action == 'commit-once':
        return p['base']+p['delta']
    if action == 'owner-cleanup':
        return [x for x in p['overlays'] if x['menu']!=p['menu']]
    if action == 'supported':
        return p['previewable'] and p['reversible']
    if action == 'exit-mode':
        return 'commit' if p['reason']=='execute' else 'restore'
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('base contract', solve('base', {'base':N,'current_preview':N+5,'delta':2}), N+2)
check('cancel contract', solve('cancel', {'base':N,'current':N+3}), N)
check('commit-once contract', solve('commit-once', {'base':N,'preview':N+2,'delta':2}), N+2)
check('owner-cleanup contract', solve('owner-cleanup', {'overlays':[{'menu':'a','id':N},{'menu':'b','id':N+1}],'menu':'a'}), [{'menu':'b','id':N+1}])
check('supported contract', solve('supported', {'previewable':True,'reversible':False,'command':N}), False)
check('exit-mode contract', solve('exit-mode', {'reason':'leave','owner':N}), 'restore')
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'base':
        return p['base']+p['delta']
    if action == 'cancel':
        return 0
    if action == 'commit-once':
        return p['base']+p['delta']
    if action == 'owner-cleanup':
        return [x for x in p['overlays'] if x['menu']!=p['menu']]
    if action == 'supported':
        return p['previewable'] and p['reversible']
    if action == 'exit-mode':
        return 'commit' if p['reason']=='execute' else 'restore'
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('base contract', solve('base', {'base':N,'current_preview':N+5,'delta':2}), N+2)
check('cancel contract', solve('cancel', {'base':N,'current':N+3}), N)
check('commit-once contract', solve('commit-once', {'base':N,'preview':N+2,'delta':2}), N+2)
check('owner-cleanup contract', solve('owner-cleanup', {'overlays':[{'menu':'a','id':N},{'menu':'b','id':N+1}],'menu':'a'}), [{'menu':'b','id':N+1}])
check('supported contract', solve('supported', {'previewable':True,'reversible':False,'command':N}), False)
check('exit-mode contract', solve('exit-mode', {'reason':'leave','owner':N}), 'restore')
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Cancelling a menu preview leaves provisional document changes.

Hover previews are provisional document overlays; changing preview restores the base, commit applies the actual command once and cancellation removes only the menu-owned preview.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'base':
        return p['base']+p['delta']
    if action == 'cancel':
        return p['base']
    if action == 'commit-once':
        return p['preview']+p['delta']
    if action == 'owner-cleanup':
        return [x for x in p['overlays'] if x['menu']!=p['menu']]
    if action == 'supported':
        return p['previewable'] and p['reversible']
    if action == 'exit-mode':
        return 'commit' if p['reason']=='execute' else 'restore'
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('base contract', solve('base', {'base':N,'current_preview':N+5,'delta':2}), N+2)
check('cancel contract', solve('cancel', {'base':N,'current':N+3}), N)
check('commit-once contract', solve('commit-once', {'base':N,'preview':N+2,'delta':2}), N+2)
check('owner-cleanup contract', solve('owner-cleanup', {'overlays':[{'menu':'a','id':N},{'menu':'b','id':N+1}],'menu':'a'}), [{'menu':'b','id':N+1}])
check('supported contract', solve('supported', {'previewable':True,'reversible':False,'command':N}), False)
check('exit-mode contract', solve('exit-mode', {'reason':'leave','owner':N}), 'restore')
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'base':
        return p['base']+p['delta']
    if action == 'cancel':
        return p['base']
    if action == 'commit-once':
        return p['base']
    if action == 'owner-cleanup':
        return [x for x in p['overlays'] if x['menu']!=p['menu']]
    if action == 'supported':
        return p['previewable'] and p['reversible']
    if action == 'exit-mode':
        return 'commit' if p['reason']=='execute' else 'restore'
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('base contract', solve('base', {'base':N,'current_preview':N+5,'delta':2}), N+2)
check('cancel contract', solve('cancel', {'base':N,'current':N+3}), N)
check('commit-once contract', solve('commit-once', {'base':N,'preview':N+2,'delta':2}), N+2)
check('owner-cleanup contract', solve('owner-cleanup', {'overlays':[{'menu':'a','id':N},{'menu':'b','id':N+1}],'menu':'a'}), [{'menu':'b','id':N+1}])
check('supported contract', solve('supported', {'previewable':True,'reversible':False,'command':N}), False)
check('exit-mode contract', solve('exit-mode', {'reason':'leave','owner':N}), 'restore')
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Menu preview commit applies the command delta twice.

Hover previews are provisional document overlays; changing preview restores the base, commit applies the actual command once and cancellation removes only the menu-owned preview.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'base':
        return p['base']+p['delta']
    if action == 'cancel':
        return p['base']
    if action == 'commit-once':
        return p['base']+p['delta']
    if action == 'owner-cleanup':
        return []
    if action == 'supported':
        return p['previewable'] and p['reversible']
    if action == 'exit-mode':
        return 'commit' if p['reason']=='execute' else 'restore'
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('base contract', solve('base', {'base':N,'current_preview':N+5,'delta':2}), N+2)
check('cancel contract', solve('cancel', {'base':N,'current':N+3}), N)
check('commit-once contract', solve('commit-once', {'base':N,'preview':N+2,'delta':2}), N+2)
check('owner-cleanup contract', solve('owner-cleanup', {'overlays':[{'menu':'a','id':N},{'menu':'b','id':N+1}],'menu':'a'}), [{'menu':'b','id':N+1}])
check('supported contract', solve('supported', {'previewable':True,'reversible':False,'command':N}), False)
check('exit-mode contract', solve('exit-mode', {'reason':'leave','owner':N}), 'restore')
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'base':
        return p['base']+p['delta']
    if action == 'cancel':
        return p['base']
    if action == 'commit-once':
        return p['base']+p['delta']
    if action == 'owner-cleanup':
        return p['overlays']
    if action == 'supported':
        return p['previewable'] and p['reversible']
    if action == 'exit-mode':
        return 'commit' if p['reason']=='execute' else 'restore'
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('base contract', solve('base', {'base':N,'current_preview':N+5,'delta':2}), N+2)
check('cancel contract', solve('cancel', {'base':N,'current':N+3}), N)
check('commit-once contract', solve('commit-once', {'base':N,'preview':N+2,'delta':2}), N+2)
check('owner-cleanup contract', solve('owner-cleanup', {'overlays':[{'menu':'a','id':N},{'menu':'b','id':N+1}],'menu':'a'}), [{'menu':'b','id':N+1}])
check('supported contract', solve('supported', {'previewable':True,'reversible':False,'command':N}), False)
check('exit-mode contract', solve('exit-mode', {'reason':'leave','owner':N}), 'restore')
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Menu preview cleanup removes overlays owned by another menu.

Hover previews are provisional document overlays; changing preview restores the base, commit applies the actual command once and cancellation removes only the menu-owned preview.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'base':
        return p['base']+p['delta']
    if action == 'cancel':
        return p['base']
    if action == 'commit-once':
        return p['base']+p['delta']
    if action == 'owner-cleanup':
        return [x for x in p['overlays'] if x['menu']!=p['menu']]
    if action == 'supported':
        return p['previewable']
    if action == 'exit-mode':
        return 'commit' if p['reason']=='execute' else 'restore'
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('base contract', solve('base', {'base':N,'current_preview':N+5,'delta':2}), N+2)
check('cancel contract', solve('cancel', {'base':N,'current':N+3}), N)
check('commit-once contract', solve('commit-once', {'base':N,'preview':N+2,'delta':2}), N+2)
check('owner-cleanup contract', solve('owner-cleanup', {'overlays':[{'menu':'a','id':N},{'menu':'b','id':N+1}],'menu':'a'}), [{'menu':'b','id':N+1}])
check('supported contract', solve('supported', {'previewable':True,'reversible':False,'command':N}), False)
check('exit-mode contract', solve('exit-mode', {'reason':'leave','owner':N}), 'restore')
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'base':
        return p['base']+p['delta']
    if action == 'cancel':
        return p['base']
    if action == 'commit-once':
        return p['base']+p['delta']
    if action == 'owner-cleanup':
        return [x for x in p['overlays'] if x['menu']!=p['menu']]
    if action == 'supported':
        return p['previewable'] or p['reversible']
    if action == 'exit-mode':
        return 'commit' if p['reason']=='execute' else 'restore'
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('base contract', solve('base', {'base':N,'current_preview':N+5,'delta':2}), N+2)
check('cancel contract', solve('cancel', {'base':N,'current':N+3}), N)
check('commit-once contract', solve('commit-once', {'base':N,'preview':N+2,'delta':2}), N+2)
check('owner-cleanup contract', solve('owner-cleanup', {'overlays':[{'menu':'a','id':N},{'menu':'b','id':N+1}],'menu':'a'}), [{'menu':'b','id':N+1}])
check('supported contract', solve('supported', {'previewable':True,'reversible':False,'command':N}), False)
check('exit-mode contract', solve('exit-mode', {'reason':'leave','owner':N}), 'restore')
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Irreversible menu command is executed as a hover preview.

Hover previews are provisional document overlays; changing preview restores the base, commit applies the actual command once and cancellation removes only the menu-owned preview.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'base':
        return p['base']+p['delta']
    if action == 'cancel':
        return p['base']
    if action == 'commit-once':
        return p['base']+p['delta']
    if action == 'owner-cleanup':
        return [x for x in p['overlays'] if x['menu']!=p['menu']]
    if action == 'supported':
        return p['previewable'] and p['reversible']
    if action == 'exit-mode':
        return 'commit'
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('base contract', solve('base', {'base':N,'current_preview':N+5,'delta':2}), N+2)
check('cancel contract', solve('cancel', {'base':N,'current':N+3}), N)
check('commit-once contract', solve('commit-once', {'base':N,'preview':N+2,'delta':2}), N+2)
check('owner-cleanup contract', solve('owner-cleanup', {'overlays':[{'menu':'a','id':N},{'menu':'b','id':N+1}],'menu':'a'}), [{'menu':'b','id':N+1}])
check('supported contract', solve('supported', {'previewable':True,'reversible':False,'command':N}), False)
check('exit-mode contract', solve('exit-mode', {'reason':'leave','owner':N}), 'restore')
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'base':
        return p['base']+p['delta']
    if action == 'cancel':
        return p['base']
    if action == 'commit-once':
        return p['base']+p['delta']
    if action == 'owner-cleanup':
        return [x for x in p['overlays'] if x['menu']!=p['menu']]
    if action == 'supported':
        return p['previewable'] and p['reversible']
    if action == 'exit-mode':
        return 'restore' if p['reason']=='cancel' else 'commit'
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('base contract', solve('base', {'base':N,'current_preview':N+5,'delta':2}), N+2)
check('cancel contract', solve('cancel', {'base':N,'current':N+3}), N)
check('commit-once contract', solve('commit-once', {'base':N,'preview':N+2,'delta':2}), N+2)
check('owner-cleanup contract', solve('owner-cleanup', {'overlays':[{'menu':'a','id':N},{'menu':'b','id':N+1}],'menu':'a'}), [{'menu':'b','id':N+1}])
check('supported contract', solve('supported', {'previewable':True,'reversible':False,'command':N}), False)
check('exit-mode contract', solve('exit-mode', {'reason':'leave','owner':N}), 'restore')
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Pointer departure commits a provisional menu preview.

Hover previews are provisional document overlays; changing preview restores the base, commit applies the actual command once and cancellation removes only the menu-owned preview.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'impression-once':
        return len(p)
    if action == 'invoked-vs-success':
        return {'invoked':len(p),'succeeded':sum(x['success'] for x in p)}
    if action == 'path-dimension':
        return '/'.join(p['path'])
    if action == 'duration':
        return max(0,p['closed']-p['opened'])
    if action == 'arguments':
        return {k:v for k,v in p.items() if k in ('command','path','outcome')}
    if action == 'session-count':
        return len({x['root_session'] for x in p})
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('impression-once contract', solve('impression-once', [N,N,N+1]), 2)
check('invoked-vs-success contract', solve('invoked-vs-success', [{'success':True,'id':N},{'success':False,'id':N+1}]), {'invoked':2,'succeeded':1})
check('path-dimension contract', solve('path-dimension', {'path':['root','tools',str(N)]}), 'root/tools/'+str(N))
check('duration contract', solve('duration', {'opened':N,'closed':N+7}), 7)
check('arguments contract', solve('arguments', {'command':'copy','path':['root'], 'arguments':{'doc':N},'target':'doc'}), {'command':'copy','path':['root']})
check('session-count contract', solve('session-count', [{'root_session':N,'surface':'a'},{'root_session':N,'surface':'b'}]), 1)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'impression-once':
        return int(bool(p))
    if action == 'invoked-vs-success':
        return {'invoked':len(p),'succeeded':sum(x['success'] for x in p)}
    if action == 'path-dimension':
        return '/'.join(p['path'])
    if action == 'duration':
        return max(0,p['closed']-p['opened'])
    if action == 'arguments':
        return {k:v for k,v in p.items() if k in ('command','path','outcome')}
    if action == 'session-count':
        return len({x['root_session'] for x in p})
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('impression-once contract', solve('impression-once', [N,N,N+1]), 2)
check('invoked-vs-success contract', solve('invoked-vs-success', [{'success':True,'id':N},{'success':False,'id':N+1}]), {'invoked':2,'succeeded':1})
check('path-dimension contract', solve('path-dimension', {'path':['root','tools',str(N)]}), 'root/tools/'+str(N))
check('duration contract', solve('duration', {'opened':N,'closed':N+7}), 7)
check('arguments contract', solve('arguments', {'command':'copy','path':['root'], 'arguments':{'doc':N},'target':'doc'}), {'command':'copy','path':['root']})
check('session-count contract', solve('session-count', [{'root_session':N,'surface':'a'},{'root_session':N,'surface':'b'}]), 1)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Repeated row renders inflate menu impression counts.

Menu metrics distinguish impressions, command invocation and completed execution; root sessions and menu paths remain separate dimensions and sensitive arguments are excluded.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'impression-once':
        return len(set(p))
    if action == 'invoked-vs-success':
        return {'invoked':sum(x['success'] for x in p),'succeeded':sum(x['success'] for x in p)}
    if action == 'path-dimension':
        return '/'.join(p['path'])
    if action == 'duration':
        return max(0,p['closed']-p['opened'])
    if action == 'arguments':
        return {k:v for k,v in p.items() if k in ('command','path','outcome')}
    if action == 'session-count':
        return len({x['root_session'] for x in p})
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('impression-once contract', solve('impression-once', [N,N,N+1]), 2)
check('invoked-vs-success contract', solve('invoked-vs-success', [{'success':True,'id':N},{'success':False,'id':N+1}]), {'invoked':2,'succeeded':1})
check('path-dimension contract', solve('path-dimension', {'path':['root','tools',str(N)]}), 'root/tools/'+str(N))
check('duration contract', solve('duration', {'opened':N,'closed':N+7}), 7)
check('arguments contract', solve('arguments', {'command':'copy','path':['root'], 'arguments':{'doc':N},'target':'doc'}), {'command':'copy','path':['root']})
check('session-count contract', solve('session-count', [{'root_session':N,'surface':'a'},{'root_session':N,'surface':'b'}]), 1)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'impression-once':
        return len(set(p))
    if action == 'invoked-vs-success':
        return {'invoked':len(p),'succeeded':len(p)}
    if action == 'path-dimension':
        return '/'.join(p['path'])
    if action == 'duration':
        return max(0,p['closed']-p['opened'])
    if action == 'arguments':
        return {k:v for k,v in p.items() if k in ('command','path','outcome')}
    if action == 'session-count':
        return len({x['root_session'] for x in p})
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('impression-once contract', solve('impression-once', [N,N,N+1]), 2)
check('invoked-vs-success contract', solve('invoked-vs-success', [{'success':True,'id':N},{'success':False,'id':N+1}]), {'invoked':2,'succeeded':1})
check('path-dimension contract', solve('path-dimension', {'path':['root','tools',str(N)]}), 'root/tools/'+str(N))
check('duration contract', solve('duration', {'opened':N,'closed':N+7}), 7)
check('arguments contract', solve('arguments', {'command':'copy','path':['root'], 'arguments':{'doc':N},'target':'doc'}), {'command':'copy','path':['root']})
check('session-count contract', solve('session-count', [{'root_session':N,'surface':'a'},{'root_session':N,'surface':'b'}]), 1)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Menu metrics conflate invoked commands with successful execution.

Menu metrics distinguish impressions, command invocation and completed execution; root sessions and menu paths remain separate dimensions and sensitive arguments are excluded.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'impression-once':
        return len(set(p))
    if action == 'invoked-vs-success':
        return {'invoked':len(p),'succeeded':sum(x['success'] for x in p)}
    if action == 'path-dimension':
        return p['path'][-1]
    if action == 'duration':
        return max(0,p['closed']-p['opened'])
    if action == 'arguments':
        return {k:v for k,v in p.items() if k in ('command','path','outcome')}
    if action == 'session-count':
        return len({x['root_session'] for x in p})
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('impression-once contract', solve('impression-once', [N,N,N+1]), 2)
check('invoked-vs-success contract', solve('invoked-vs-success', [{'success':True,'id':N},{'success':False,'id':N+1}]), {'invoked':2,'succeeded':1})
check('path-dimension contract', solve('path-dimension', {'path':['root','tools',str(N)]}), 'root/tools/'+str(N))
check('duration contract', solve('duration', {'opened':N,'closed':N+7}), 7)
check('arguments contract', solve('arguments', {'command':'copy','path':['root'], 'arguments':{'doc':N},'target':'doc'}), {'command':'copy','path':['root']})
check('session-count contract', solve('session-count', [{'root_session':N,'surface':'a'},{'root_session':N,'surface':'b'}]), 1)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'impression-once':
        return len(set(p))
    if action == 'invoked-vs-success':
        return {'invoked':len(p),'succeeded':sum(x['success'] for x in p)}
    if action == 'path-dimension':
        return p['path'][0]
    if action == 'duration':
        return max(0,p['closed']-p['opened'])
    if action == 'arguments':
        return {k:v for k,v in p.items() if k in ('command','path','outcome')}
    if action == 'session-count':
        return len({x['root_session'] for x in p})
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('impression-once contract', solve('impression-once', [N,N,N+1]), 2)
check('invoked-vs-success contract', solve('invoked-vs-success', [{'success':True,'id':N},{'success':False,'id':N+1}]), {'invoked':2,'succeeded':1})
check('path-dimension contract', solve('path-dimension', {'path':['root','tools',str(N)]}), 'root/tools/'+str(N))
check('duration contract', solve('duration', {'opened':N,'closed':N+7}), 7)
check('arguments contract', solve('arguments', {'command':'copy','path':['root'], 'arguments':{'doc':N},'target':'doc'}), {'command':'copy','path':['root']})
check('session-count contract', solve('session-count', [{'root_session':N,'surface':'a'},{'root_session':N,'surface':'b'}]), 1)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Menu usage metrics merge repeated command labels from different branches.

Menu metrics distinguish impressions, command invocation and completed execution; root sessions and menu paths remain separate dimensions and sensitive arguments are excluded.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'impression-once':
        return len(set(p))
    if action == 'invoked-vs-success':
        return {'invoked':len(p),'succeeded':sum(x['success'] for x in p)}
    if action == 'path-dimension':
        return '/'.join(p['path'])
    if action == 'duration':
        return p['closed']
    if action == 'arguments':
        return {k:v for k,v in p.items() if k in ('command','path','outcome')}
    if action == 'session-count':
        return len({x['root_session'] for x in p})
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('impression-once contract', solve('impression-once', [N,N,N+1]), 2)
check('invoked-vs-success contract', solve('invoked-vs-success', [{'success':True,'id':N},{'success':False,'id':N+1}]), {'invoked':2,'succeeded':1})
check('path-dimension contract', solve('path-dimension', {'path':['root','tools',str(N)]}), 'root/tools/'+str(N))
check('duration contract', solve('duration', {'opened':N,'closed':N+7}), 7)
check('arguments contract', solve('arguments', {'command':'copy','path':['root'], 'arguments':{'doc':N},'target':'doc'}), {'command':'copy','path':['root']})
check('session-count contract', solve('session-count', [{'root_session':N,'surface':'a'},{'root_session':N,'surface':'b'}]), 1)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'impression-once':
        return len(set(p))
    if action == 'invoked-vs-success':
        return {'invoked':len(p),'succeeded':sum(x['success'] for x in p)}
    if action == 'path-dimension':
        return '/'.join(p['path'])
    if action == 'duration':
        return p['opened']-p['closed']
    if action == 'arguments':
        return {k:v for k,v in p.items() if k in ('command','path','outcome')}
    if action == 'session-count':
        return len({x['root_session'] for x in p})
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('impression-once contract', solve('impression-once', [N,N,N+1]), 2)
check('invoked-vs-success contract', solve('invoked-vs-success', [{'success':True,'id':N},{'success':False,'id':N+1}]), {'invoked':2,'succeeded':1})
check('path-dimension contract', solve('path-dimension', {'path':['root','tools',str(N)]}), 'root/tools/'+str(N))
check('duration contract', solve('duration', {'opened':N,'closed':N+7}), 7)
check('arguments contract', solve('arguments', {'command':'copy','path':['root'], 'arguments':{'doc':N},'target':'doc'}), {'command':'copy','path':['root']})
check('session-count contract', solve('session-count', [{'root_session':N,'surface':'a'},{'root_session':N,'surface':'b'}]), 1)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Menu dwell duration is reported as an absolute closing timestamp.

Menu metrics distinguish impressions, command invocation and completed execution; root sessions and menu paths remain separate dimensions and sensitive arguments are excluded.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'impression-once':
        return len(set(p))
    if action == 'invoked-vs-success':
        return {'invoked':len(p),'succeeded':sum(x['success'] for x in p)}
    if action == 'path-dimension':
        return '/'.join(p['path'])
    if action == 'duration':
        return max(0,p['closed']-p['opened'])
    if action == 'arguments':
        return p
    if action == 'session-count':
        return len({x['root_session'] for x in p})
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('impression-once contract', solve('impression-once', [N,N,N+1]), 2)
check('invoked-vs-success contract', solve('invoked-vs-success', [{'success':True,'id':N},{'success':False,'id':N+1}]), {'invoked':2,'succeeded':1})
check('path-dimension contract', solve('path-dimension', {'path':['root','tools',str(N)]}), 'root/tools/'+str(N))
check('duration contract', solve('duration', {'opened':N,'closed':N+7}), 7)
check('arguments contract', solve('arguments', {'command':'copy','path':['root'], 'arguments':{'doc':N},'target':'doc'}), {'command':'copy','path':['root']})
check('session-count contract', solve('session-count', [{'root_session':N,'surface':'a'},{'root_session':N,'surface':'b'}]), 1)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'impression-once':
        return len(set(p))
    if action == 'invoked-vs-success':
        return {'invoked':len(p),'succeeded':sum(x['success'] for x in p)}
    if action == 'path-dimension':
        return '/'.join(p['path'])
    if action == 'duration':
        return max(0,p['closed']-p['opened'])
    if action == 'arguments':
        return {k:v for k,v in p.items() if k!='target'}
    if action == 'session-count':
        return len({x['root_session'] for x in p})
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('impression-once contract', solve('impression-once', [N,N,N+1]), 2)
check('invoked-vs-success contract', solve('invoked-vs-success', [{'success':True,'id':N},{'success':False,'id':N+1}]), {'invoked':2,'succeeded':1})
check('path-dimension contract', solve('path-dimension', {'path':['root','tools',str(N)]}), 'root/tools/'+str(N))
check('duration contract', solve('duration', {'opened':N,'closed':N+7}), 7)
check('arguments contract', solve('arguments', {'command':'copy','path':['root'], 'arguments':{'doc':N},'target':'doc'}), {'command':'copy','path':['root']})
check('session-count contract', solve('session-count', [{'root_session':N,'surface':'a'},{'root_session':N,'surface':'b'}]), 1)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Menu usage event leaks captured command arguments.

Menu metrics distinguish impressions, command invocation and completed execution; root sessions and menu paths remain separate dimensions and sensitive arguments are excluded.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'impression-once':
        return len(set(p))
    if action == 'invoked-vs-success':
        return {'invoked':len(p),'succeeded':sum(x['success'] for x in p)}
    if action == 'path-dimension':
        return '/'.join(p['path'])
    if action == 'duration':
        return max(0,p['closed']-p['opened'])
    if action == 'arguments':
        return {k:v for k,v in p.items() if k in ('command','path','outcome')}
    if action == 'session-count':
        return len(p)
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('impression-once contract', solve('impression-once', [N,N,N+1]), 2)
check('invoked-vs-success contract', solve('invoked-vs-success', [{'success':True,'id':N},{'success':False,'id':N+1}]), {'invoked':2,'succeeded':1})
check('path-dimension contract', solve('path-dimension', {'path':['root','tools',str(N)]}), 'root/tools/'+str(N))
check('duration contract', solve('duration', {'opened':N,'closed':N+7}), 7)
check('arguments contract', solve('arguments', {'command':'copy','path':['root'], 'arguments':{'doc':N},'target':'doc'}), {'command':'copy','path':['root']})
check('session-count contract', solve('session-count', [{'root_session':N,'surface':'a'},{'root_session':N,'surface':'b'}]), 1)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'impression-once':
        return len(set(p))
    if action == 'invoked-vs-success':
        return {'invoked':len(p),'succeeded':sum(x['success'] for x in p)}
    if action == 'path-dimension':
        return '/'.join(p['path'])
    if action == 'duration':
        return max(0,p['closed']-p['opened'])
    if action == 'arguments':
        return {k:v for k,v in p.items() if k in ('command','path','outcome')}
    if action == 'session-count':
        return len({x['surface'] for x in p})
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('impression-once contract', solve('impression-once', [N,N,N+1]), 2)
check('invoked-vs-success contract', solve('invoked-vs-success', [{'success':True,'id':N},{'success':False,'id':N+1}]), {'invoked':2,'succeeded':1})
check('path-dimension contract', solve('path-dimension', {'path':['root','tools',str(N)]}), 'root/tools/'+str(N))
check('duration contract', solve('duration', {'opened':N,'closed':N+7}), 7)
check('arguments contract', solve('arguments', {'command':'copy','path':['root'], 'arguments':{'doc':N},'target':'doc'}), {'command':'copy','path':['root']})
check('session-count contract', solve('session-count', [{'root_session':N,'surface':'a'},{'root_session':N,'surface':'b'}]), 1)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
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:
Submenu openings count as separate root menu sessions.

Menu metrics distinguish impressions, command invocation and completed execution; root sessions and menu paths remain separate dimensions and sensitive arguments are excluded.

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 = {('visible', 'pointer-enter'): 'expired', ('hover-paused', 'pointer-leave'): 'visible', ('visible', 'page-hidden'): 'hidden-paused', ('hidden-paused', 'page-visible'): 'visible', ('hover-paused', 'page-hidden'): 'both-paused', ('both-paused', 'page-visible'): 'hover-paused', ('both-paused', 'pointer-leave'): 'hidden-paused', ('visible', 'budget-consumed'): 'expired', ('expired', 'late-pointer-enter'): 'expired', ('hidden-paused', 'budget-callback'): 'hidden-paused'}
    data = json.loads(json.dumps({'remaining': 10, 'pause_owners': [], 'spent': 0})) if payload is None else {**json.loads(json.dumps({'remaining': 10, 'pause_owners': [], 'spent': 0})), **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 == 'pointer-enter': data['pause_owners'] = sorted(set(data['pause_owners']) | {'pointer'})
            if event == 'page-hidden': data['pause_owners'] = sorted(set(data['pause_owners']) | {'page'})
            if event == 'pointer-leave': data['pause_owners'] = [x for x in data['pause_owners'] if x != 'pointer']
            if event == 'page-visible': data['pause_owners'] = [x for x in data['pause_owners'] if x != 'page']
            if event in ('budget-consumed', 'budget-callback'):
                elapsed = max(0, arg.get('elapsed', data['remaining']))
                charge = 0 if data['pause_owners'] else min(elapsed, data['remaining'])
                data['remaining'] -= charge
                data['spent'] += charge
                if data['remaining'] > 0 and event == 'budget-consumed': event = 'unknown-event'
            state = table.get((state, event), state)
            if state == 'expired': data['remaining'] = 0
    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('visible / pointer-enter', solve('visible', [('pointer-enter', N)], N), 'hover-paused')
check('hover-paused / pointer-leave', solve('hover-paused', [('pointer-leave', N)], N), 'visible')
check('visible / page-hidden', solve('visible', [('page-hidden', N)], N), 'hidden-paused')
check('hidden-paused / page-visible', solve('hidden-paused', [('page-visible', N)], N), 'visible')
check('hover-paused / page-hidden', solve('hover-paused', [('page-hidden', N)], N), 'both-paused')
check('both-paused / page-visible', solve('both-paused', [('page-visible', N)], N), 'hover-paused')
check('both-paused / pointer-leave', solve('both-paused', [('pointer-leave', N)], N), 'hidden-paused')
check('visible / budget-consumed', solve('visible', [('budget-consumed', N)], N), 'expired')
check('expired / late-pointer-enter', solve('expired', [('late-pointer-enter', N)], N), 'expired')
check('hidden-paused / budget-callback', solve('hidden-paused', [('budget-callback', N)], N), 'hidden-paused')
check('older notification incarnation', solve('visible', [('pointer-enter', N - 1)], N), 'visible')
check('future notification incarnation', solve('visible', [('pointer-enter', N + 1)], N), 'visible')
check('unknown event is inert', solve('visible', [('unknown-event', N)], N), 'visible')
check('empty delivery batch', solve('visible', [], N), 'visible')
check('N stale deliveries before current delivery', solve('visible', [('pointer-enter', N - 1)] * N + [('pointer-enter', N)], N), 'hover-paused')
check('trace pointer-enter then pointer-leave', solve('visible', [('pointer-enter', N), ('pointer-leave', N)], N), 'visible')
check('trace pointer-enter then page-hidden', solve('visible', [('pointer-enter', N), ('page-hidden', N)], N), 'both-paused')
check('trace pointer-leave then pointer-enter', solve('hover-paused', [('pointer-leave', N), ('pointer-enter', N)], N), 'hover-paused')
check('trace pointer-leave then page-hidden', solve('hover-paused', [('pointer-leave', N), ('page-hidden', N)], N), 'hidden-paused')
check('trace pointer-leave then budget-consumed', solve('hover-paused', [('pointer-leave', N), ('budget-consumed', N)], N), 'expired')
check('trace page-hidden then page-visible', solve('visible', [('page-hidden', N), ('page-visible', N)], N), 'visible')
check('trace page-hidden then budget-callback', solve('visible', [('page-hidden', N), ('budget-callback', N)], N), 'hidden-paused')
check('trace page-visible then pointer-enter', solve('hidden-paused', [('page-visible', N), ('pointer-enter', N)], N), 'hover-paused')
check('trace page-visible then page-hidden', solve('hidden-paused', [('page-visible', N), ('page-hidden', N)], N), 'hidden-paused')
check('trace page-visible then budget-consumed', solve('hidden-paused', [('page-visible', N), ('budget-consumed', N)], N), 'expired')
check('trace page-hidden then page-visible', solve('hover-paused', [('page-hidden', N), ('page-visible', N)], N), 'hover-paused')
check('trace page-hidden then pointer-leave', solve('hover-paused', [('page-hidden', N), ('pointer-leave', N)], N), 'hidden-paused')
check('trace page-visible then pointer-leave', solve('both-paused', [('page-visible', N), ('pointer-leave', N)], N), 'visible')
check('trace page-visible then page-hidden', solve('both-paused', [('page-visible', N), ('page-hidden', N)], N), 'both-paused')
check('trace pointer-leave then page-visible', solve('both-paused', [('pointer-leave', N), ('page-visible', N)], N), 'visible')
check('trace pointer-leave then budget-callback', solve('both-paused', [('pointer-leave', N), ('budget-callback', N)], N), 'hidden-paused')
check('trace budget-consumed then late-pointer-enter', solve('visible', [('budget-consumed', N), ('late-pointer-enter', N)], N), 'expired')
check('trace late-pointer-enter then late-pointer-enter', solve('expired', [('late-pointer-enter', N), ('late-pointer-enter', N)], N), 'expired')
check('trace budget-callback then page-visible', solve('hidden-paused', [('budget-callback', N), ('page-visible', N)], N), 'visible')
check('trace budget-callback then budget-callback', solve('hidden-paused', [('budget-callback', N), ('budget-callback', N)], N), 'hidden-paused')
check('domain state regression 1: remaining', solve('visible', [('budget-consumed', N, {'elapsed': 3})], N, {}, 'remaining'), {'phase': 'visible', 'value': 7})
check('domain state regression 2: spent', solve('visible', [('budget-consumed', N, {'elapsed': 20})], N, {}, 'spent'), {'phase': 'expired', 'value': 10})
check('domain state regression 3: remaining', solve('visible', [('pointer-enter', N, {}), ('budget-callback', N, {'elapsed': 20})], N, {}, 'remaining'), {'phase': 'hover-paused', 'value': 10})
check('domain state regression 4: pause_owners', solve('both-paused', [('pointer-leave', N, {})], N, {'pause_owners': ['page', 'pointer']}, 'pause_owners'), {'phase': 'hidden-paused', 'value': ['page']})
check('domain state regression 5: pause_owners', solve('both-paused', [('page-visible', N, {})], N, {'pause_owners': ['page', 'pointer']}, 'pause_owners'), {'phase': 'hover-paused', 'value': ['pointer']})
check('domain state regression 6: spent', solve('visible', [('budget-consumed', N, {'elapsed': -2})], N, {}, 'spent'), {'phase': 'visible', 'value': 0})
check('domain state regression 7: remaining', solve('visible', [('pointer-enter', N, {}), ('page-hidden', N, {}), ('pointer-leave', N, {}), ('budget-callback', N, {'elapsed': 99})], N, {}, 'remaining'), {'phase': 'hidden-paused', 'value': 10})
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 = {('visible', 'pointer-enter'): 'visible', ('hover-paused', 'pointer-leave'): 'visible', ('visible', 'page-hidden'): 'hidden-paused', ('hidden-paused', 'page-visible'): 'visible', ('hover-paused', 'page-hidden'): 'both-paused', ('both-paused', 'page-visible'): 'hover-paused', ('both-paused', 'pointer-leave'): 'hidden-paused', ('visible', 'budget-consumed'): 'expired', ('expired', 'late-pointer-enter'): 'expired', ('hidden-paused', 'budget-callback'): 'hidden-paused'}
    data = json.loads(json.dumps({'remaining': 10, 'pause_owners': [], 'spent': 0})) if payload is None else {**json.loads(json.dumps({'remaining': 10, 'pause_owners': [], 'spent': 0})), **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 == 'pointer-enter': data['pause_owners'] = sorted(set(data['pause_owners']) | {'pointer'})
            if event == 'page-hidden': data['pause_owners'] = sorted(set(data['pause_owners']) | {'page'})
            if event == 'pointer-leave': data['pause_owners'] = [x for x in data['pause_owners'] if x != 'pointer']
            if event == 'page-visible': data['pause_owners'] = [x for x in data['pause_owners'] if x != 'page']
            if event in ('budget-consumed', 'budget-callback'):
                elapsed = max(0, arg.get('elapsed', data['remaining']))
                charge = 0 if data['pause_owners'] else min(elapsed, data['remaining'])
                data['remaining'] -= charge
                data['spent'] += charge
                if data['remaining'] > 0 and event == 'budget-consumed': event = 'unknown-event'
            state = table.get((state, event), state)
            if state == 'expired': data['remaining'] = 0
    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('visible / pointer-enter', solve('visible', [('pointer-enter', N)], N), 'hover-paused')
check('hover-paused / pointer-leave', solve('hover-paused', [('pointer-leave', N)], N), 'visible')
check('visible / page-hidden', solve('visible', [('page-hidden', N)], N), 'hidden-paused')
check('hidden-paused / page-visible', solve('hidden-paused', [('page-visible', N)], N), 'visible')
check('hover-paused / page-hidden', solve('hover-paused', [('page-hidden', N)], N), 'both-paused')
check('both-paused / page-visible', solve('both-paused', [('page-visible', N)], N), 'hover-paused')
check('both-paused / pointer-leave', solve('both-paused', [('pointer-leave', N)], N), 'hidden-paused')
check('visible / budget-consumed', solve('visible', [('budget-consumed', N)], N), 'expired')
check('expired / late-pointer-enter', solve('expired', [('late-pointer-enter', N)], N), 'expired')
check('hidden-paused / budget-callback', solve('hidden-paused', [('budget-callback', N)], N), 'hidden-paused')
check('older notification incarnation', solve('visible', [('pointer-enter', N - 1)], N), 'visible')
check('future notification incarnation', solve('visible', [('pointer-enter', N + 1)], N), 'visible')
check('unknown event is inert', solve('visible', [('unknown-event', N)], N), 'visible')
check('empty delivery batch', solve('visible', [], N), 'visible')
check('N stale deliveries before current delivery', solve('visible', [('pointer-enter', N - 1)] * N + [('pointer-enter', N)], N), 'hover-paused')
check('trace pointer-enter then pointer-leave', solve('visible', [('pointer-enter', N), ('pointer-leave', N)], N), 'visible')
check('trace pointer-enter then page-hidden', solve('visible', [('pointer-enter', N), ('page-hidden', N)], N), 'both-paused')
check('trace pointer-leave then pointer-enter', solve('hover-paused', [('pointer-leave', N), ('pointer-enter', N)], N), 'hover-paused')
check('trace pointer-leave then page-hidden', solve('hover-paused', [('pointer-leave', N), ('page-hidden', N)], N), 'hidden-paused')
check('trace pointer-leave then budget-consumed', solve('hover-paused', [('pointer-leave', N), ('budget-consumed', N)], N), 'expired')
check('trace page-hidden then page-visible', solve('visible', [('page-hidden', N), ('page-visible', N)], N), 'visible')
check('trace page-hidden then budget-callback', solve('visible', [('page-hidden', N), ('budget-callback', N)], N), 'hidden-paused')
check('trace page-visible then pointer-enter', solve('hidden-paused', [('page-visible', N), ('pointer-enter', N)], N), 'hover-paused')
check('trace page-visible then page-hidden', solve('hidden-paused', [('page-visible', N), ('page-hidden', N)], N), 'hidden-paused')
check('trace page-visible then budget-consumed', solve('hidden-paused', [('page-visible', N), ('budget-consumed', N)], N), 'expired')
check('trace page-hidden then page-visible', solve('hover-paused', [('page-hidden', N), ('page-visible', N)], N), 'hover-paused')
check('trace page-hidden then pointer-leave', solve('hover-paused', [('page-hidden', N), ('pointer-leave', N)], N), 'hidden-paused')
check('trace page-visible then pointer-leave', solve('both-paused', [('page-visible', N), ('pointer-leave', N)], N), 'visible')
check('trace page-visible then page-hidden', solve('both-paused', [('page-visible', N), ('page-hidden', N)], N), 'both-paused')
check('trace pointer-leave then page-visible', solve('both-paused', [('pointer-leave', N), ('page-visible', N)], N), 'visible')
check('trace pointer-leave then budget-callback', solve('both-paused', [('pointer-leave', N), ('budget-callback', N)], N), 'hidden-paused')
check('trace budget-consumed then late-pointer-enter', solve('visible', [('budget-consumed', N), ('late-pointer-enter', N)], N), 'expired')
check('trace late-pointer-enter then late-pointer-enter', solve('expired', [('late-pointer-enter', N), ('late-pointer-enter', N)], N), 'expired')
check('trace budget-callback then page-visible', solve('hidden-paused', [('budget-callback', N), ('page-visible', N)], N), 'visible')
check('trace budget-callback then budget-callback', solve('hidden-paused', [('budget-callback', N), ('budget-callback', N)], N), 'hidden-paused')
check('domain state regression 1: remaining', solve('visible', [('budget-consumed', N, {'elapsed': 3})], N, {}, 'remaining'), {'phase': 'visible', 'value': 7})
check('domain state regression 2: spent', solve('visible', [('budget-consumed', N, {'elapsed': 20})], N, {}, 'spent'), {'phase': 'expired', 'value': 10})
check('domain state regression 3: remaining', solve('visible', [('pointer-enter', N, {}), ('budget-callback', N, {'elapsed': 20})], N, {}, 'remaining'), {'phase': 'hover-paused', 'value': 10})
check('domain state regression 4: pause_owners', solve('both-paused', [('pointer-leave', N, {})], N, {'pause_owners': ['page', 'pointer']}, 'pause_owners'), {'phase': 'hidden-paused', 'value': ['page']})
check('domain state regression 5: pause_owners', solve('both-paused', [('page-visible', N, {})], N, {'pause_owners': ['page', 'pointer']}, 'pause_owners'), {'phase': 'hover-paused', 'value': ['pointer']})
check('domain state regression 6: spent', solve('visible', [('budget-consumed', N, {'elapsed': -2})], N, {}, 'spent'), {'phase': 'visible', 'value': 0})
check('domain state regression 7: remaining', solve('visible', [('pointer-enter', N, {}), ('page-hidden', N, {}), ('pointer-leave', N, {}), ('budget-callback', N, {'elapsed': 99})], N, {}, 'remaining'), {'phase': 'hidden-paused', 'value': 10})
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 pointer-enter event leaves a notification in expired instead of hover-paused.

Toast exposure timeout is a bounded visual-notification workflow with mutable policy state {'remaining': 10, 'pause_owners': [], 'spent': 0}. Its default transition relation is {('visible', 'pointer-enter'): 'hover-paused', ('hover-paused', 'pointer-leave'): 'visible', ('visible', 'page-hidden'): 'hidden-paused', ('hidden-paused', 'page-visible'): 'visible', ('hover-paused', 'page-hidden'): 'both-paused', ('both-paused', 'page-visible'): 'hover-paused', ('both-paused', 'pointer-leave'): 'hidden-paused', ('visible', 'budget-consumed'): 'expired', ('expired', 'late-pointer-enter'): 'expired', ('hidden-paused', 'budget-callback'): 'hidden-paused'}; 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