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 == 'namespace':
        return p['provider']+':'+p['id']
    if action == 'rank':
        return sorted(p,key=lambda x:x['rank'])
    if action == 'unload':
        return [x for x in p['rows'] if x['provider']!=p['provider']]
    if action == 'replace':
        return [p['new'] if x['provider']==p['new']['provider'] and x['id']==p['new']['id'] else x for x in p['rows']]
    if action == 'disabled-provider':
        return [x for x in p['rows'] if x['provider'] not in p['disabled']]
    if action == 'revision-owner':
        return max(p['revision'].values())
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('namespace contract', solve('namespace', {'provider':'ext'+str(N),'id':'open'}), 'ext'+str(N)+':open')
check('rank contract', solve('rank', [{'id':'z','rank':N},{'id':'a','rank':N+1}]), [{'id':'z','rank':N},{'id':'a','rank':N+1}])
check('unload contract', solve('unload', {'rows':[{'provider':'a','id':N},{'provider':'b','id':N+1}],'provider':'a'}), [{'provider':'b','id':N+1}])
check('replace contract', solve('replace', {'rows':[{'provider':'a','id':N,'v':0},{'provider':'b','id':N,'v':0}],'new':{'provider':'b','id':N,'v':1}}), [{'provider':'a','id':N,'v':0},{'provider':'b','id':N,'v':1}])
check('disabled-provider contract', solve('disabled-provider', {'rows':[{'provider':'off','id':N},{'provider':'on','id':N+1}],'disabled':['off']}), [{'provider':'on','id':N+1}])
check('revision-owner contract', solve('revision-owner', {'provider':'a','revision':{'a':N,'b':N+10}}), N)
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 == 'namespace':
        return p['provider']+':'+p['id']
    if action == 'rank':
        return sorted(p,key=lambda x:x['rank'])
    if action == 'unload':
        return [x for x in p['rows'] if x['provider']!=p['provider']]
    if action == 'replace':
        return [p['new'] if x['provider']==p['new']['provider'] and x['id']==p['new']['id'] else x for x in p['rows']]
    if action == 'disabled-provider':
        return [x for x in p['rows'] if x['provider'] not in p['disabled']]
    if action == 'revision-owner':
        return sum(p['revision'].values())
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('namespace contract', solve('namespace', {'provider':'ext'+str(N),'id':'open'}), 'ext'+str(N)+':open')
check('rank contract', solve('rank', [{'id':'z','rank':N},{'id':'a','rank':N+1}]), [{'id':'z','rank':N},{'id':'a','rank':N+1}])
check('unload contract', solve('unload', {'rows':[{'provider':'a','id':N},{'provider':'b','id':N+1}],'provider':'a'}), [{'provider':'b','id':N+1}])
check('replace contract', solve('replace', {'rows':[{'provider':'a','id':N,'v':0},{'provider':'b','id':N,'v':0}],'new':{'provider':'b','id':N,'v':1}}), [{'provider':'a','id':N,'v':0},{'provider':'b','id':N,'v':1}])
check('disabled-provider contract', solve('disabled-provider', {'rows':[{'provider':'off','id':N},{'provider':'on','id':N+1}],'disabled':['off']}), [{'provider':'on','id':N+1}])
check('revision-owner contract', solve('revision-owner', {'provider':'a','revision':{'a':N,'b':N+10}}), N)
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:
Contribution revision is borrowed from another provider.

Contributed menu commands are namespaced, rank-stable, and replaceable only by their provider; removals retain unrelated content.

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 == 'roots':
        return [x['id'] for x in p]
    if action == 'children':
        return [x['id'] for x in p['nodes'] if x['parent']==p['parent']]
    if action == 'split-default':
        return p['default'] in [x['command'] for x in p['children'] if x['kind']=='command']
    if action == 'self-cycle':
        return any(x['id']==x['parent'] for x in p)
    if action == 'presentation-ids':
        return len({x['row'] for x in p})==len(p)
    if action == 'depth-budget':
        return p['depth']+p['incoming']<=p['limit']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('roots contract', solve('roots', [{'id':0,'parent':None},{'id':N,'parent':0}]), [0])
check('children contract', solve('children', {'parent':'a','nodes':[{'id':N,'parent':'a'},{'id':N+1,'parent':'b'}]}), [N])
check('split-default contract', solve('split-default', {'default':'remote'+str(N),'registry':['remote'+str(N)],'children':[{'kind':'submenu','descendants':['remote'+str(N)]}]}), False)
check('self-cycle contract', solve('self-cycle', [{'id':N,'parent':N},{'id':N+1,'parent':None}]), True)
check('presentation-ids contract', solve('presentation-ids', [{'row':N,'command':'copy','label':'Copy'},{'row':N+1,'command':'copy','label':'Copy'}]), True)
check('depth-budget contract', solve('depth-budget', {'depth':N+2,'incoming':4,'limit':N+4}), 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 == 'roots':
        return [x['id'] for x in p if not x['parent']]
    if action == 'children':
        return [x['id'] for x in p['nodes'] if x['parent']==p['parent']]
    if action == 'split-default':
        return p['default'] in [x['command'] for x in p['children'] if x['kind']=='command']
    if action == 'self-cycle':
        return any(x['id']==x['parent'] for x in p)
    if action == 'presentation-ids':
        return len({x['row'] for x in p})==len(p)
    if action == 'depth-budget':
        return p['depth']+p['incoming']<=p['limit']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('roots contract', solve('roots', [{'id':0,'parent':None},{'id':N,'parent':0}]), [0])
check('children contract', solve('children', {'parent':'a','nodes':[{'id':N,'parent':'a'},{'id':N+1,'parent':'b'}]}), [N])
check('split-default contract', solve('split-default', {'default':'remote'+str(N),'registry':['remote'+str(N)],'children':[{'kind':'submenu','descendants':['remote'+str(N)]}]}), False)
check('self-cycle contract', solve('self-cycle', [{'id':N,'parent':N},{'id':N+1,'parent':None}]), True)
check('presentation-ids contract', solve('presentation-ids', [{'row':N,'command':'copy','label':'Copy'},{'row':N+1,'command':'copy','label':'Copy'}]), True)
check('depth-budget contract', solve('depth-budget', {'depth':N+2,'incoming':4,'limit':N+4}), 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:
A valid zero-valued parent is interpreted as a menu root.

Menu definitions validate presentation identity separately from semantic command identity. Split-menu defaults belong to immediate command children; ancestry and depth remain bounded.

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 == 'roots':
        return [x['id'] for x in p if x['parent'] is None]
    if action == 'children':
        return [x['id'] for x in p['nodes']]
    if action == 'split-default':
        return p['default'] in [x['command'] for x in p['children'] if x['kind']=='command']
    if action == 'self-cycle':
        return any(x['id']==x['parent'] for x in p)
    if action == 'presentation-ids':
        return len({x['row'] for x in p})==len(p)
    if action == 'depth-budget':
        return p['depth']+p['incoming']<=p['limit']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('roots contract', solve('roots', [{'id':0,'parent':None},{'id':N,'parent':0}]), [0])
check('children contract', solve('children', {'parent':'a','nodes':[{'id':N,'parent':'a'},{'id':N+1,'parent':'b'}]}), [N])
check('split-default contract', solve('split-default', {'default':'remote'+str(N),'registry':['remote'+str(N)],'children':[{'kind':'submenu','descendants':['remote'+str(N)]}]}), False)
check('self-cycle contract', solve('self-cycle', [{'id':N,'parent':N},{'id':N+1,'parent':None}]), True)
check('presentation-ids contract', solve('presentation-ids', [{'row':N,'command':'copy','label':'Copy'},{'row':N+1,'command':'copy','label':'Copy'}]), True)
check('depth-budget contract', solve('depth-budget', {'depth':N+2,'incoming':4,'limit':N+4}), 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 == 'roots':
        return [x['id'] for x in p if x['parent'] is None]
    if action == 'children':
        return [x['id'] for x in p['nodes'] if x['id']==p['parent']]
    if action == 'split-default':
        return p['default'] in [x['command'] for x in p['children'] if x['kind']=='command']
    if action == 'self-cycle':
        return any(x['id']==x['parent'] for x in p)
    if action == 'presentation-ids':
        return len({x['row'] for x in p})==len(p)
    if action == 'depth-budget':
        return p['depth']+p['incoming']<=p['limit']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('roots contract', solve('roots', [{'id':0,'parent':None},{'id':N,'parent':0}]), [0])
check('children contract', solve('children', {'parent':'a','nodes':[{'id':N,'parent':'a'},{'id':N+1,'parent':'b'}]}), [N])
check('split-default contract', solve('split-default', {'default':'remote'+str(N),'registry':['remote'+str(N)],'children':[{'kind':'submenu','descendants':['remote'+str(N)]}]}), False)
check('self-cycle contract', solve('self-cycle', [{'id':N,'parent':N},{'id':N+1,'parent':None}]), True)
check('presentation-ids contract', solve('presentation-ids', [{'row':N,'command':'copy','label':'Copy'},{'row':N+1,'command':'copy','label':'Copy'}]), True)
check('depth-budget contract', solve('depth-budget', {'depth':N+2,'incoming':4,'limit':N+4}), 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:
Submenu child enumeration leaks sibling commands.

Menu definitions validate presentation identity separately from semantic command identity. Split-menu defaults belong to immediate command children; ancestry and depth remain bounded.

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 == 'roots':
        return [x['id'] for x in p if x['parent'] is None]
    if action == 'children':
        return [x['id'] for x in p['nodes'] if x['parent']==p['parent']]
    if action == 'split-default':
        return p['default'] in p['registry']
    if action == 'self-cycle':
        return any(x['id']==x['parent'] for x in p)
    if action == 'presentation-ids':
        return len({x['row'] for x in p})==len(p)
    if action == 'depth-budget':
        return p['depth']+p['incoming']<=p['limit']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('roots contract', solve('roots', [{'id':0,'parent':None},{'id':N,'parent':0}]), [0])
check('children contract', solve('children', {'parent':'a','nodes':[{'id':N,'parent':'a'},{'id':N+1,'parent':'b'}]}), [N])
check('split-default contract', solve('split-default', {'default':'remote'+str(N),'registry':['remote'+str(N)],'children':[{'kind':'submenu','descendants':['remote'+str(N)]}]}), False)
check('self-cycle contract', solve('self-cycle', [{'id':N,'parent':N},{'id':N+1,'parent':None}]), True)
check('presentation-ids contract', solve('presentation-ids', [{'row':N,'command':'copy','label':'Copy'},{'row':N+1,'command':'copy','label':'Copy'}]), True)
check('depth-budget contract', solve('depth-budget', {'depth':N+2,'incoming':4,'limit':N+4}), 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 == 'roots':
        return [x['id'] for x in p if x['parent'] is None]
    if action == 'children':
        return [x['id'] for x in p['nodes'] if x['parent']==p['parent']]
    if action == 'split-default':
        return any(p['default'] in x.get('descendants',[]) for x in p['children'])
    if action == 'self-cycle':
        return any(x['id']==x['parent'] for x in p)
    if action == 'presentation-ids':
        return len({x['row'] for x in p})==len(p)
    if action == 'depth-budget':
        return p['depth']+p['incoming']<=p['limit']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('roots contract', solve('roots', [{'id':0,'parent':None},{'id':N,'parent':0}]), [0])
check('children contract', solve('children', {'parent':'a','nodes':[{'id':N,'parent':'a'},{'id':N+1,'parent':'b'}]}), [N])
check('split-default contract', solve('split-default', {'default':'remote'+str(N),'registry':['remote'+str(N)],'children':[{'kind':'submenu','descendants':['remote'+str(N)]}]}), False)
check('self-cycle contract', solve('self-cycle', [{'id':N,'parent':N},{'id':N+1,'parent':None}]), True)
check('presentation-ids contract', solve('presentation-ids', [{'row':N,'command':'copy','label':'Copy'},{'row':N+1,'command':'copy','label':'Copy'}]), True)
check('depth-budget contract', solve('depth-budget', {'depth':N+2,'incoming':4,'limit':N+4}), 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:
Split menu owner accepts a default command outside its direct child commands.

Menu definitions validate presentation identity separately from semantic command identity. Split-menu defaults belong to immediate command children; ancestry and depth remain bounded.

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 == 'roots':
        return [x['id'] for x in p if x['parent'] is None]
    if action == 'children':
        return [x['id'] for x in p['nodes'] if x['parent']==p['parent']]
    if action == 'split-default':
        return p['default'] in [x['command'] for x in p['children'] if x['kind']=='command']
    if action == 'self-cycle':
        return False
    if action == 'presentation-ids':
        return len({x['row'] for x in p})==len(p)
    if action == 'depth-budget':
        return p['depth']+p['incoming']<=p['limit']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('roots contract', solve('roots', [{'id':0,'parent':None},{'id':N,'parent':0}]), [0])
check('children contract', solve('children', {'parent':'a','nodes':[{'id':N,'parent':'a'},{'id':N+1,'parent':'b'}]}), [N])
check('split-default contract', solve('split-default', {'default':'remote'+str(N),'registry':['remote'+str(N)],'children':[{'kind':'submenu','descendants':['remote'+str(N)]}]}), False)
check('self-cycle contract', solve('self-cycle', [{'id':N,'parent':N},{'id':N+1,'parent':None}]), True)
check('presentation-ids contract', solve('presentation-ids', [{'row':N,'command':'copy','label':'Copy'},{'row':N+1,'command':'copy','label':'Copy'}]), True)
check('depth-budget contract', solve('depth-budget', {'depth':N+2,'incoming':4,'limit':N+4}), 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 == 'roots':
        return [x['id'] for x in p if x['parent'] is None]
    if action == 'children':
        return [x['id'] for x in p['nodes'] if x['parent']==p['parent']]
    if action == 'split-default':
        return p['default'] in [x['command'] for x in p['children'] if x['kind']=='command']
    if action == 'self-cycle':
        return all(x['id']==x['parent'] for x in p)
    if action == 'presentation-ids':
        return len({x['row'] for x in p})==len(p)
    if action == 'depth-budget':
        return p['depth']+p['incoming']<=p['limit']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('roots contract', solve('roots', [{'id':0,'parent':None},{'id':N,'parent':0}]), [0])
check('children contract', solve('children', {'parent':'a','nodes':[{'id':N,'parent':'a'},{'id':N+1,'parent':'b'}]}), [N])
check('split-default contract', solve('split-default', {'default':'remote'+str(N),'registry':['remote'+str(N)],'children':[{'kind':'submenu','descendants':['remote'+str(N)]}]}), False)
check('self-cycle contract', solve('self-cycle', [{'id':N,'parent':N},{'id':N+1,'parent':None}]), True)
check('presentation-ids contract', solve('presentation-ids', [{'row':N,'command':'copy','label':'Copy'},{'row':N+1,'command':'copy','label':'Copy'}]), True)
check('depth-budget contract', solve('depth-budget', {'depth':N+2,'incoming':4,'limit':N+4}), 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:
A self-owning submenu bypasses cycle validation.

Menu definitions validate presentation identity separately from semantic command identity. Split-menu defaults belong to immediate command children; ancestry and depth remain bounded.

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 == 'roots':
        return [x['id'] for x in p if x['parent'] is None]
    if action == 'children':
        return [x['id'] for x in p['nodes'] if x['parent']==p['parent']]
    if action == 'split-default':
        return p['default'] in [x['command'] for x in p['children'] if x['kind']=='command']
    if action == 'self-cycle':
        return any(x['id']==x['parent'] for x in p)
    if action == 'presentation-ids':
        return len({x['command'] for x in p})==len(p)
    if action == 'depth-budget':
        return p['depth']+p['incoming']<=p['limit']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('roots contract', solve('roots', [{'id':0,'parent':None},{'id':N,'parent':0}]), [0])
check('children contract', solve('children', {'parent':'a','nodes':[{'id':N,'parent':'a'},{'id':N+1,'parent':'b'}]}), [N])
check('split-default contract', solve('split-default', {'default':'remote'+str(N),'registry':['remote'+str(N)],'children':[{'kind':'submenu','descendants':['remote'+str(N)]}]}), False)
check('self-cycle contract', solve('self-cycle', [{'id':N,'parent':N},{'id':N+1,'parent':None}]), True)
check('presentation-ids contract', solve('presentation-ids', [{'row':N,'command':'copy','label':'Copy'},{'row':N+1,'command':'copy','label':'Copy'}]), True)
check('depth-budget contract', solve('depth-budget', {'depth':N+2,'incoming':4,'limit':N+4}), 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 == 'roots':
        return [x['id'] for x in p if x['parent'] is None]
    if action == 'children':
        return [x['id'] for x in p['nodes'] if x['parent']==p['parent']]
    if action == 'split-default':
        return p['default'] in [x['command'] for x in p['children'] if x['kind']=='command']
    if action == 'self-cycle':
        return any(x['id']==x['parent'] for x in p)
    if action == 'presentation-ids':
        return len({(x['command'],x['label']) for x in p})==len(p)
    if action == 'depth-budget':
        return p['depth']+p['incoming']<=p['limit']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('roots contract', solve('roots', [{'id':0,'parent':None},{'id':N,'parent':0}]), [0])
check('children contract', solve('children', {'parent':'a','nodes':[{'id':N,'parent':'a'},{'id':N+1,'parent':'b'}]}), [N])
check('split-default contract', solve('split-default', {'default':'remote'+str(N),'registry':['remote'+str(N)],'children':[{'kind':'submenu','descendants':['remote'+str(N)]}]}), False)
check('self-cycle contract', solve('self-cycle', [{'id':N,'parent':N},{'id':N+1,'parent':None}]), True)
check('presentation-ids contract', solve('presentation-ids', [{'row':N,'command':'copy','label':'Copy'},{'row':N+1,'command':'copy','label':'Copy'}]), True)
check('depth-budget contract', solve('depth-budget', {'depth':N+2,'incoming':4,'limit':N+4}), 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 validator rejects separate presentation rows for the same command.

Menu definitions validate presentation identity separately from semantic command identity. Split-menu defaults belong to immediate command children; ancestry and depth remain bounded.

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 == 'roots':
        return [x['id'] for x in p if x['parent'] is None]
    if action == 'children':
        return [x['id'] for x in p['nodes'] if x['parent']==p['parent']]
    if action == 'split-default':
        return p['default'] in [x['command'] for x in p['children'] if x['kind']=='command']
    if action == 'self-cycle':
        return any(x['id']==x['parent'] for x in p)
    if action == 'presentation-ids':
        return len({x['row'] for x in p})==len(p)
    if action == 'depth-budget':
        return p['depth']<=p['limit']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('roots contract', solve('roots', [{'id':0,'parent':None},{'id':N,'parent':0}]), [0])
check('children contract', solve('children', {'parent':'a','nodes':[{'id':N,'parent':'a'},{'id':N+1,'parent':'b'}]}), [N])
check('split-default contract', solve('split-default', {'default':'remote'+str(N),'registry':['remote'+str(N)],'children':[{'kind':'submenu','descendants':['remote'+str(N)]}]}), False)
check('self-cycle contract', solve('self-cycle', [{'id':N,'parent':N},{'id':N+1,'parent':None}]), True)
check('presentation-ids contract', solve('presentation-ids', [{'row':N,'command':'copy','label':'Copy'},{'row':N+1,'command':'copy','label':'Copy'}]), True)
check('depth-budget contract', solve('depth-budget', {'depth':N+2,'incoming':4,'limit':N+4}), 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 == 'roots':
        return [x['id'] for x in p if x['parent'] is None]
    if action == 'children':
        return [x['id'] for x in p['nodes'] if x['parent']==p['parent']]
    if action == 'split-default':
        return p['default'] in [x['command'] for x in p['children'] if x['kind']=='command']
    if action == 'self-cycle':
        return any(x['id']==x['parent'] for x in p)
    if action == 'presentation-ids':
        return len({x['row'] for x in p})==len(p)
    if action == 'depth-budget':
        return p['incoming']<=p['limit']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('roots contract', solve('roots', [{'id':0,'parent':None},{'id':N,'parent':0}]), [0])
check('children contract', solve('children', {'parent':'a','nodes':[{'id':N,'parent':'a'},{'id':N+1,'parent':'b'}]}), [N])
check('split-default contract', solve('split-default', {'default':'remote'+str(N),'registry':['remote'+str(N)],'children':[{'kind':'submenu','descendants':['remote'+str(N)]}]}), False)
check('self-cycle contract', solve('self-cycle', [{'id':N,'parent':N},{'id':N+1,'parent':None}]), True)
check('presentation-ids contract', solve('presentation-ids', [{'row':N,'command':'copy','label':'Copy'},{'row':N+1,'command':'copy','label':'Copy'}]), True)
check('depth-budget contract', solve('depth-budget', {'depth':N+2,'incoming':4,'limit':N+4}), 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:
Nested provider menu exceeds the remaining cascade depth budget.

Menu definitions validate presentation identity separately from semantic command identity. Split-menu defaults belong to immediate command children; ancestry and depth remain bounded.

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 == 'nearest':
        return next((x['owner'] for x in p['chain'] if p['command'] in x['handles']),None)
    if action == 'unsupported':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'origin':
        return p['invocation_origin']
    if action == 'args':
        return dict(p['defaults'],**p['invocation'])
    if action == 'stop':
        return p['handled'] or p['cancelled']
    if action == 'result-owner':
        return {'command':p['command'],'handler':p['handler'],'origin':p['origin']}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nearest contract', solve('nearest', {'command':'c'+str(N),'chain':[{'owner':'root','handles':['c'+str(N)]},{'owner':'child','handles':['c'+str(N)]}]}), 'child')
check('unsupported contract', solve('unsupported', {'command':'missing'+str(N),'chain':[{'owner':'root','handles':['a']},{'owner':'child','handles':['b']}]}), None)
check('origin contract', solve('origin', {'invocation_origin':'row'+str(N),'handler_owner':'panel','root_owner':'app'}), 'row'+str(N))
check('args contract', solve('args', {'defaults':{'count':1,'mode':'copy'},'invocation':{'count':N+1}}), {'count':N+1,'mode':'copy'})
check('stop contract', solve('stop', {'handled':False,'cancelled':True,'serial':N}), True)
check('result-owner contract', solve('result-owner', {'command':str(N),'handler':'app','origin':'context'}), {'command':str(N),'handler':'app','origin':'context'})
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 == 'nearest':
        return p['chain'][0]['owner']
    if action == 'unsupported':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'origin':
        return p['invocation_origin']
    if action == 'args':
        return dict(p['defaults'],**p['invocation'])
    if action == 'stop':
        return p['handled'] or p['cancelled']
    if action == 'result-owner':
        return {'command':p['command'],'handler':p['handler'],'origin':p['origin']}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nearest contract', solve('nearest', {'command':'c'+str(N),'chain':[{'owner':'root','handles':['c'+str(N)]},{'owner':'child','handles':['c'+str(N)]}]}), 'child')
check('unsupported contract', solve('unsupported', {'command':'missing'+str(N),'chain':[{'owner':'root','handles':['a']},{'owner':'child','handles':['b']}]}), None)
check('origin contract', solve('origin', {'invocation_origin':'row'+str(N),'handler_owner':'panel','root_owner':'app'}), 'row'+str(N))
check('args contract', solve('args', {'defaults':{'count':1,'mode':'copy'},'invocation':{'count':N+1}}), {'count':N+1,'mode':'copy'})
check('stop contract', solve('stop', {'handled':False,'cancelled':True,'serial':N}), True)
check('result-owner contract', solve('result-owner', {'command':str(N),'handler':'app','origin':'context'}), {'command':str(N),'handler':'app','origin':'context'})
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:
Root menu handler masks a nearer command handler.

Menu dispatch resolves the nearest ancestor handler accepting the command, preserving a command origin distinct from the handler owner.

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 == 'nearest':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'unsupported':
        return p['chain'][-1]['owner']
    if action == 'origin':
        return p['invocation_origin']
    if action == 'args':
        return dict(p['defaults'],**p['invocation'])
    if action == 'stop':
        return p['handled'] or p['cancelled']
    if action == 'result-owner':
        return {'command':p['command'],'handler':p['handler'],'origin':p['origin']}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nearest contract', solve('nearest', {'command':'c'+str(N),'chain':[{'owner':'root','handles':['c'+str(N)]},{'owner':'child','handles':['c'+str(N)]}]}), 'child')
check('unsupported contract', solve('unsupported', {'command':'missing'+str(N),'chain':[{'owner':'root','handles':['a']},{'owner':'child','handles':['b']}]}), None)
check('origin contract', solve('origin', {'invocation_origin':'row'+str(N),'handler_owner':'panel','root_owner':'app'}), 'row'+str(N))
check('args contract', solve('args', {'defaults':{'count':1,'mode':'copy'},'invocation':{'count':N+1}}), {'count':N+1,'mode':'copy'})
check('stop contract', solve('stop', {'handled':False,'cancelled':True,'serial':N}), True)
check('result-owner contract', solve('result-owner', {'command':str(N),'handler':'app','origin':'context'}), {'command':str(N),'handler':'app','origin':'context'})
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 == 'nearest':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'unsupported':
        return p['chain'][0]['owner']
    if action == 'origin':
        return p['invocation_origin']
    if action == 'args':
        return dict(p['defaults'],**p['invocation'])
    if action == 'stop':
        return p['handled'] or p['cancelled']
    if action == 'result-owner':
        return {'command':p['command'],'handler':p['handler'],'origin':p['origin']}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nearest contract', solve('nearest', {'command':'c'+str(N),'chain':[{'owner':'root','handles':['c'+str(N)]},{'owner':'child','handles':['c'+str(N)]}]}), 'child')
check('unsupported contract', solve('unsupported', {'command':'missing'+str(N),'chain':[{'owner':'root','handles':['a']},{'owner':'child','handles':['b']}]}), None)
check('origin contract', solve('origin', {'invocation_origin':'row'+str(N),'handler_owner':'panel','root_owner':'app'}), 'row'+str(N))
check('args contract', solve('args', {'defaults':{'count':1,'mode':'copy'},'invocation':{'count':N+1}}), {'count':N+1,'mode':'copy'})
check('stop contract', solve('stop', {'handled':False,'cancelled':True,'serial':N}), True)
check('result-owner contract', solve('result-owner', {'command':str(N),'handler':'app','origin':'context'}), {'command':str(N),'handler':'app','origin':'context'})
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:
Unsupported menu command is dispatched to an arbitrary owner.

Menu dispatch resolves the nearest ancestor handler accepting the command, preserving a command origin distinct from the handler owner.

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 == 'nearest':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'unsupported':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'origin':
        return p['handler_owner']
    if action == 'args':
        return dict(p['defaults'],**p['invocation'])
    if action == 'stop':
        return p['handled'] or p['cancelled']
    if action == 'result-owner':
        return {'command':p['command'],'handler':p['handler'],'origin':p['origin']}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nearest contract', solve('nearest', {'command':'c'+str(N),'chain':[{'owner':'root','handles':['c'+str(N)]},{'owner':'child','handles':['c'+str(N)]}]}), 'child')
check('unsupported contract', solve('unsupported', {'command':'missing'+str(N),'chain':[{'owner':'root','handles':['a']},{'owner':'child','handles':['b']}]}), None)
check('origin contract', solve('origin', {'invocation_origin':'row'+str(N),'handler_owner':'panel','root_owner':'app'}), 'row'+str(N))
check('args contract', solve('args', {'defaults':{'count':1,'mode':'copy'},'invocation':{'count':N+1}}), {'count':N+1,'mode':'copy'})
check('stop contract', solve('stop', {'handled':False,'cancelled':True,'serial':N}), True)
check('result-owner contract', solve('result-owner', {'command':str(N),'handler':'app','origin':'context'}), {'command':str(N),'handler':'app','origin':'context'})
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 == 'nearest':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'unsupported':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'origin':
        return p['root_owner']
    if action == 'args':
        return dict(p['defaults'],**p['invocation'])
    if action == 'stop':
        return p['handled'] or p['cancelled']
    if action == 'result-owner':
        return {'command':p['command'],'handler':p['handler'],'origin':p['origin']}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nearest contract', solve('nearest', {'command':'c'+str(N),'chain':[{'owner':'root','handles':['c'+str(N)]},{'owner':'child','handles':['c'+str(N)]}]}), 'child')
check('unsupported contract', solve('unsupported', {'command':'missing'+str(N),'chain':[{'owner':'root','handles':['a']},{'owner':'child','handles':['b']}]}), None)
check('origin contract', solve('origin', {'invocation_origin':'row'+str(N),'handler_owner':'panel','root_owner':'app'}), 'row'+str(N))
check('args contract', solve('args', {'defaults':{'count':1,'mode':'copy'},'invocation':{'count':N+1}}), {'count':N+1,'mode':'copy'})
check('stop contract', solve('stop', {'handled':False,'cancelled':True,'serial':N}), True)
check('result-owner contract', solve('result-owner', {'command':str(N),'handler':'app','origin':'context'}), {'command':str(N),'handler':'app','origin':'context'})
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:
Command origin is rewritten while bubbling through menu owners.

Menu dispatch resolves the nearest ancestor handler accepting the command, preserving a command origin distinct from the handler owner.

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 == 'nearest':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'unsupported':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'origin':
        return p['invocation_origin']
    if action == 'args':
        return dict(p['invocation'],**p['defaults'])
    if action == 'stop':
        return p['handled'] or p['cancelled']
    if action == 'result-owner':
        return {'command':p['command'],'handler':p['handler'],'origin':p['origin']}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nearest contract', solve('nearest', {'command':'c'+str(N),'chain':[{'owner':'root','handles':['c'+str(N)]},{'owner':'child','handles':['c'+str(N)]}]}), 'child')
check('unsupported contract', solve('unsupported', {'command':'missing'+str(N),'chain':[{'owner':'root','handles':['a']},{'owner':'child','handles':['b']}]}), None)
check('origin contract', solve('origin', {'invocation_origin':'row'+str(N),'handler_owner':'panel','root_owner':'app'}), 'row'+str(N))
check('args contract', solve('args', {'defaults':{'count':1,'mode':'copy'},'invocation':{'count':N+1}}), {'count':N+1,'mode':'copy'})
check('stop contract', solve('stop', {'handled':False,'cancelled':True,'serial':N}), True)
check('result-owner contract', solve('result-owner', {'command':str(N),'handler':'app','origin':'context'}), {'command':str(N),'handler':'app','origin':'context'})
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 == 'nearest':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'unsupported':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'origin':
        return p['invocation_origin']
    if action == 'args':
        return p['defaults']
    if action == 'stop':
        return p['handled'] or p['cancelled']
    if action == 'result-owner':
        return {'command':p['command'],'handler':p['handler'],'origin':p['origin']}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nearest contract', solve('nearest', {'command':'c'+str(N),'chain':[{'owner':'root','handles':['c'+str(N)]},{'owner':'child','handles':['c'+str(N)]}]}), 'child')
check('unsupported contract', solve('unsupported', {'command':'missing'+str(N),'chain':[{'owner':'root','handles':['a']},{'owner':'child','handles':['b']}]}), None)
check('origin contract', solve('origin', {'invocation_origin':'row'+str(N),'handler_owner':'panel','root_owner':'app'}), 'row'+str(N))
check('args contract', solve('args', {'defaults':{'count':1,'mode':'copy'},'invocation':{'count':N+1}}), {'count':N+1,'mode':'copy'})
check('stop contract', solve('stop', {'handled':False,'cancelled':True,'serial':N}), True)
check('result-owner contract', solve('result-owner', {'command':str(N),'handler':'app','origin':'context'}), {'command':str(N),'handler':'app','origin':'context'})
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 invocation arguments lose precedence to command defaults.

Menu dispatch resolves the nearest ancestor handler accepting the command, preserving a command origin distinct from the handler owner.

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 == 'nearest':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'unsupported':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'origin':
        return p['invocation_origin']
    if action == 'args':
        return dict(p['defaults'],**p['invocation'])
    if action == 'stop':
        return p['handled']
    if action == 'result-owner':
        return {'command':p['command'],'handler':p['handler'],'origin':p['origin']}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nearest contract', solve('nearest', {'command':'c'+str(N),'chain':[{'owner':'root','handles':['c'+str(N)]},{'owner':'child','handles':['c'+str(N)]}]}), 'child')
check('unsupported contract', solve('unsupported', {'command':'missing'+str(N),'chain':[{'owner':'root','handles':['a']},{'owner':'child','handles':['b']}]}), None)
check('origin contract', solve('origin', {'invocation_origin':'row'+str(N),'handler_owner':'panel','root_owner':'app'}), 'row'+str(N))
check('args contract', solve('args', {'defaults':{'count':1,'mode':'copy'},'invocation':{'count':N+1}}), {'count':N+1,'mode':'copy'})
check('stop contract', solve('stop', {'handled':False,'cancelled':True,'serial':N}), True)
check('result-owner contract', solve('result-owner', {'command':str(N),'handler':'app','origin':'context'}), {'command':str(N),'handler':'app','origin':'context'})
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 == 'nearest':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'unsupported':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'origin':
        return p['invocation_origin']
    if action == 'args':
        return dict(p['defaults'],**p['invocation'])
    if action == 'stop':
        return p['handled'] and p['cancelled']
    if action == 'result-owner':
        return {'command':p['command'],'handler':p['handler'],'origin':p['origin']}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nearest contract', solve('nearest', {'command':'c'+str(N),'chain':[{'owner':'root','handles':['c'+str(N)]},{'owner':'child','handles':['c'+str(N)]}]}), 'child')
check('unsupported contract', solve('unsupported', {'command':'missing'+str(N),'chain':[{'owner':'root','handles':['a']},{'owner':'child','handles':['b']}]}), None)
check('origin contract', solve('origin', {'invocation_origin':'row'+str(N),'handler_owner':'panel','root_owner':'app'}), 'row'+str(N))
check('args contract', solve('args', {'defaults':{'count':1,'mode':'copy'},'invocation':{'count':N+1}}), {'count':N+1,'mode':'copy'})
check('stop contract', solve('stop', {'handled':False,'cancelled':True,'serial':N}), True)
check('result-owner contract', solve('result-owner', {'command':str(N),'handler':'app','origin':'context'}), {'command':str(N),'handler':'app','origin':'context'})
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:
Cancelled menu command continues through ancestor handlers.

Menu dispatch resolves the nearest ancestor handler accepting the command, preserving a command origin distinct from the handler owner.

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 == 'nearest':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'unsupported':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'origin':
        return p['invocation_origin']
    if action == 'args':
        return dict(p['defaults'],**p['invocation'])
    if action == 'stop':
        return p['handled'] or p['cancelled']
    if action == 'result-owner':
        return {'command':p['command'],'handler':p['origin'],'origin':p['origin']}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nearest contract', solve('nearest', {'command':'c'+str(N),'chain':[{'owner':'root','handles':['c'+str(N)]},{'owner':'child','handles':['c'+str(N)]}]}), 'child')
check('unsupported contract', solve('unsupported', {'command':'missing'+str(N),'chain':[{'owner':'root','handles':['a']},{'owner':'child','handles':['b']}]}), None)
check('origin contract', solve('origin', {'invocation_origin':'row'+str(N),'handler_owner':'panel','root_owner':'app'}), 'row'+str(N))
check('args contract', solve('args', {'defaults':{'count':1,'mode':'copy'},'invocation':{'count':N+1}}), {'count':N+1,'mode':'copy'})
check('stop contract', solve('stop', {'handled':False,'cancelled':True,'serial':N}), True)
check('result-owner contract', solve('result-owner', {'command':str(N),'handler':'app','origin':'context'}), {'command':str(N),'handler':'app','origin':'context'})
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 == 'nearest':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'unsupported':
        return next((x['owner'] for x in reversed(p['chain']) if p['command'] in x['handles']),None)
    if action == 'origin':
        return p['invocation_origin']
    if action == 'args':
        return dict(p['defaults'],**p['invocation'])
    if action == 'stop':
        return p['handled'] or p['cancelled']
    if action == 'result-owner':
        return {'command':p['command'],'handler':p['handler'],'origin':p['handler']}
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nearest contract', solve('nearest', {'command':'c'+str(N),'chain':[{'owner':'root','handles':['c'+str(N)]},{'owner':'child','handles':['c'+str(N)]}]}), 'child')
check('unsupported contract', solve('unsupported', {'command':'missing'+str(N),'chain':[{'owner':'root','handles':['a']},{'owner':'child','handles':['b']}]}), None)
check('origin contract', solve('origin', {'invocation_origin':'row'+str(N),'handler_owner':'panel','root_owner':'app'}), 'row'+str(N))
check('args contract', solve('args', {'defaults':{'count':1,'mode':'copy'},'invocation':{'count':N+1}}), {'count':N+1,'mode':'copy'})
check('stop contract', solve('stop', {'handled':False,'cancelled':True,'serial':N}), True)
check('result-owner contract', solve('result-owner', {'command':str(N),'handler':'app','origin':'context'}), {'command':str(N),'handler':'app','origin':'context'})
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 command result conflates execution owner and invocation origin.

Menu dispatch resolves the nearest ancestor handler accepting the command, preserving a command origin distinct from the handler owner.

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 == 'prepare':
        return 'prepared' if p['validated'] else 'rejected'
    if action == 'pending':
        return p['state']=='prepared' and not p['inflight']
    if action == 'success-close':
        return p['success'] and p['policy']=='success'
    if action == 'failure':
        return {'state':'failed','error':p['error'],'retry':p['retryable']}
    if action == 'retry-id':
        return {'command':p['command'],'attempt':p['attempt']+1,'context':p['context']}
    if action == 'completion':
        return p['transaction']==p['pending']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prepare contract', solve('prepare', {'validated':True,'authorized':False,'command':N}), 'rejected')
check('pending contract', solve('pending', {'state':'prepared','inflight':True,'id':N}), False)
check('success-close contract', solve('success-close', {'success':False,'policy':'success','id':N}), False)
check('failure contract', solve('failure', {'error':'e'+str(N),'retryable':True}), {'state':'failed','error':'e'+str(N),'retry':True})
check('retry-id contract', solve('retry-id', {'command':'copy','attempt':N,'context':'doc'}), {'command':'copy','attempt':N+1,'context':'doc'})
check('completion contract', solve('completion', {'transaction':N,'pending':N+1}), 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 == 'prepare':
        return 'prepared' if p['validated'] or p['authorized'] else 'rejected'
    if action == 'pending':
        return p['state']=='prepared' and not p['inflight']
    if action == 'success-close':
        return p['success'] and p['policy']=='success'
    if action == 'failure':
        return {'state':'failed','error':p['error'],'retry':p['retryable']}
    if action == 'retry-id':
        return {'command':p['command'],'attempt':p['attempt']+1,'context':p['context']}
    if action == 'completion':
        return p['transaction']==p['pending']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prepare contract', solve('prepare', {'validated':True,'authorized':False,'command':N}), 'rejected')
check('pending contract', solve('pending', {'state':'prepared','inflight':True,'id':N}), False)
check('success-close contract', solve('success-close', {'success':False,'policy':'success','id':N}), False)
check('failure contract', solve('failure', {'error':'e'+str(N),'retryable':True}), {'state':'failed','error':'e'+str(N),'retry':True})
check('retry-id contract', solve('retry-id', {'command':'copy','attempt':N,'context':'doc'}), {'command':'copy','attempt':N+1,'context':'doc'})
check('completion contract', solve('completion', {'transaction':N,'pending':N+1}), 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 command preparation ignores authorization.

Menu command transactions have explicit preparation, execution, success and failure phases; close policy and duplicate suppression are separate.

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 == 'prepare':
        return 'prepared' if p['validated'] and p['authorized'] else 'rejected'
    if action == 'pending':
        return p['state']=='prepared'
    if action == 'success-close':
        return p['success'] and p['policy']=='success'
    if action == 'failure':
        return {'state':'failed','error':p['error'],'retry':p['retryable']}
    if action == 'retry-id':
        return {'command':p['command'],'attempt':p['attempt']+1,'context':p['context']}
    if action == 'completion':
        return p['transaction']==p['pending']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prepare contract', solve('prepare', {'validated':True,'authorized':False,'command':N}), 'rejected')
check('pending contract', solve('pending', {'state':'prepared','inflight':True,'id':N}), False)
check('success-close contract', solve('success-close', {'success':False,'policy':'success','id':N}), False)
check('failure contract', solve('failure', {'error':'e'+str(N),'retryable':True}), {'state':'failed','error':'e'+str(N),'retry':True})
check('retry-id contract', solve('retry-id', {'command':'copy','attempt':N,'context':'doc'}), {'command':'copy','attempt':N+1,'context':'doc'})
check('completion contract', solve('completion', {'transaction':N,'pending':N+1}), 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 == 'prepare':
        return 'prepared' if p['validated'] and p['authorized'] else 'rejected'
    if action == 'pending':
        return not p['inflight'] or p['state']=='prepared'
    if action == 'success-close':
        return p['success'] and p['policy']=='success'
    if action == 'failure':
        return {'state':'failed','error':p['error'],'retry':p['retryable']}
    if action == 'retry-id':
        return {'command':p['command'],'attempt':p['attempt']+1,'context':p['context']}
    if action == 'completion':
        return p['transaction']==p['pending']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prepare contract', solve('prepare', {'validated':True,'authorized':False,'command':N}), 'rejected')
check('pending contract', solve('pending', {'state':'prepared','inflight':True,'id':N}), False)
check('success-close contract', solve('success-close', {'success':False,'policy':'success','id':N}), False)
check('failure contract', solve('failure', {'error':'e'+str(N),'retryable':True}), {'state':'failed','error':'e'+str(N),'retry':True})
check('retry-id contract', solve('retry-id', {'command':'copy','attempt':N,'context':'doc'}), {'command':'copy','attempt':N+1,'context':'doc'})
check('completion contract', solve('completion', {'transaction':N,'pending':N+1}), 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:
A prepared menu transaction launches twice while pending.

Menu command transactions have explicit preparation, execution, success and failure phases; close policy and duplicate suppression are separate.

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 == 'prepare':
        return 'prepared' if p['validated'] and p['authorized'] else 'rejected'
    if action == 'pending':
        return p['state']=='prepared' and not p['inflight']
    if action == 'success-close':
        return p['policy']=='success'
    if action == 'failure':
        return {'state':'failed','error':p['error'],'retry':p['retryable']}
    if action == 'retry-id':
        return {'command':p['command'],'attempt':p['attempt']+1,'context':p['context']}
    if action == 'completion':
        return p['transaction']==p['pending']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prepare contract', solve('prepare', {'validated':True,'authorized':False,'command':N}), 'rejected')
check('pending contract', solve('pending', {'state':'prepared','inflight':True,'id':N}), False)
check('success-close contract', solve('success-close', {'success':False,'policy':'success','id':N}), False)
check('failure contract', solve('failure', {'error':'e'+str(N),'retryable':True}), {'state':'failed','error':'e'+str(N),'retry':True})
check('retry-id contract', solve('retry-id', {'command':'copy','attempt':N,'context':'doc'}), {'command':'copy','attempt':N+1,'context':'doc'})
check('completion contract', solve('completion', {'transaction':N,'pending':N+1}), 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 == 'prepare':
        return 'prepared' if p['validated'] and p['authorized'] else 'rejected'
    if action == 'pending':
        return p['state']=='prepared' and not p['inflight']
    if action == 'success-close':
        return p['success'] or p['policy']=='success'
    if action == 'failure':
        return {'state':'failed','error':p['error'],'retry':p['retryable']}
    if action == 'retry-id':
        return {'command':p['command'],'attempt':p['attempt']+1,'context':p['context']}
    if action == 'completion':
        return p['transaction']==p['pending']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prepare contract', solve('prepare', {'validated':True,'authorized':False,'command':N}), 'rejected')
check('pending contract', solve('pending', {'state':'prepared','inflight':True,'id':N}), False)
check('success-close contract', solve('success-close', {'success':False,'policy':'success','id':N}), False)
check('failure contract', solve('failure', {'error':'e'+str(N),'retryable':True}), {'state':'failed','error':'e'+str(N),'retry':True})
check('retry-id contract', solve('retry-id', {'command':'copy','attempt':N,'context':'doc'}), {'command':'copy','attempt':N+1,'context':'doc'})
check('completion contract', solve('completion', {'transaction':N,'pending':N+1}), 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 command closes a success-only popup.

Menu command transactions have explicit preparation, execution, success and failure phases; close policy and duplicate suppression are separate.

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 == 'prepare':
        return 'prepared' if p['validated'] and p['authorized'] else 'rejected'
    if action == 'pending':
        return p['state']=='prepared' and not p['inflight']
    if action == 'success-close':
        return p['success'] and p['policy']=='success'
    if action == 'failure':
        return {'state':'done','error':None,'retry':False}
    if action == 'retry-id':
        return {'command':p['command'],'attempt':p['attempt']+1,'context':p['context']}
    if action == 'completion':
        return p['transaction']==p['pending']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prepare contract', solve('prepare', {'validated':True,'authorized':False,'command':N}), 'rejected')
check('pending contract', solve('pending', {'state':'prepared','inflight':True,'id':N}), False)
check('success-close contract', solve('success-close', {'success':False,'policy':'success','id':N}), False)
check('failure contract', solve('failure', {'error':'e'+str(N),'retryable':True}), {'state':'failed','error':'e'+str(N),'retry':True})
check('retry-id contract', solve('retry-id', {'command':'copy','attempt':N,'context':'doc'}), {'command':'copy','attempt':N+1,'context':'doc'})
check('completion contract', solve('completion', {'transaction':N,'pending':N+1}), 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 == 'prepare':
        return 'prepared' if p['validated'] and p['authorized'] else 'rejected'
    if action == 'pending':
        return p['state']=='prepared' and not p['inflight']
    if action == 'success-close':
        return p['success'] and p['policy']=='success'
    if action == 'failure':
        return {'state':'failed','error':p['error'],'retry':False}
    if action == 'retry-id':
        return {'command':p['command'],'attempt':p['attempt']+1,'context':p['context']}
    if action == 'completion':
        return p['transaction']==p['pending']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prepare contract', solve('prepare', {'validated':True,'authorized':False,'command':N}), 'rejected')
check('pending contract', solve('pending', {'state':'prepared','inflight':True,'id':N}), False)
check('success-close contract', solve('success-close', {'success':False,'policy':'success','id':N}), False)
check('failure contract', solve('failure', {'error':'e'+str(N),'retryable':True}), {'state':'failed','error':'e'+str(N),'retry':True})
check('retry-id contract', solve('retry-id', {'command':'copy','attempt':N,'context':'doc'}), {'command':'copy','attempt':N+1,'context':'doc'})
check('completion contract', solve('completion', {'transaction':N,'pending':N+1}), 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:
Recoverable menu command failure loses retry state.

Menu command transactions have explicit preparation, execution, success and failure phases; close policy and duplicate suppression are separate.

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 == 'prepare':
        return 'prepared' if p['validated'] and p['authorized'] else 'rejected'
    if action == 'pending':
        return p['state']=='prepared' and not p['inflight']
    if action == 'success-close':
        return p['success'] and p['policy']=='success'
    if action == 'failure':
        return {'state':'failed','error':p['error'],'retry':p['retryable']}
    if action == 'retry-id':
        return {'command':p['command'],'attempt':p['attempt'],'context':p['context']}
    if action == 'completion':
        return p['transaction']==p['pending']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prepare contract', solve('prepare', {'validated':True,'authorized':False,'command':N}), 'rejected')
check('pending contract', solve('pending', {'state':'prepared','inflight':True,'id':N}), False)
check('success-close contract', solve('success-close', {'success':False,'policy':'success','id':N}), False)
check('failure contract', solve('failure', {'error':'e'+str(N),'retryable':True}), {'state':'failed','error':'e'+str(N),'retry':True})
check('retry-id contract', solve('retry-id', {'command':'copy','attempt':N,'context':'doc'}), {'command':'copy','attempt':N+1,'context':'doc'})
check('completion contract', solve('completion', {'transaction':N,'pending':N+1}), 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 == 'prepare':
        return 'prepared' if p['validated'] and p['authorized'] else 'rejected'
    if action == 'pending':
        return p['state']=='prepared' and not p['inflight']
    if action == 'success-close':
        return p['success'] and p['policy']=='success'
    if action == 'failure':
        return {'state':'failed','error':p['error'],'retry':p['retryable']}
    if action == 'retry-id':
        return {'command':p['command'],'attempt':p['attempt']+1,'context':None}
    if action == 'completion':
        return p['transaction']==p['pending']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prepare contract', solve('prepare', {'validated':True,'authorized':False,'command':N}), 'rejected')
check('pending contract', solve('pending', {'state':'prepared','inflight':True,'id':N}), False)
check('success-close contract', solve('success-close', {'success':False,'policy':'success','id':N}), False)
check('failure contract', solve('failure', {'error':'e'+str(N),'retryable':True}), {'state':'failed','error':'e'+str(N),'retry':True})
check('retry-id contract', solve('retry-id', {'command':'copy','attempt':N,'context':'doc'}), {'command':'copy','attempt':N+1,'context':'doc'})
check('completion contract', solve('completion', {'transaction':N,'pending':N+1}), 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 command retry forgets its captured context.

Menu command transactions have explicit preparation, execution, success and failure phases; close policy and duplicate suppression are separate.

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 == 'prepare':
        return 'prepared' if p['validated'] and p['authorized'] else 'rejected'
    if action == 'pending':
        return p['state']=='prepared' and not p['inflight']
    if action == 'success-close':
        return p['success'] and p['policy']=='success'
    if action == 'failure':
        return {'state':'failed','error':p['error'],'retry':p['retryable']}
    if action == 'retry-id':
        return {'command':p['command'],'attempt':p['attempt']+1,'context':p['context']}
    if action == 'completion':
        return True
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prepare contract', solve('prepare', {'validated':True,'authorized':False,'command':N}), 'rejected')
check('pending contract', solve('pending', {'state':'prepared','inflight':True,'id':N}), False)
check('success-close contract', solve('success-close', {'success':False,'policy':'success','id':N}), False)
check('failure contract', solve('failure', {'error':'e'+str(N),'retryable':True}), {'state':'failed','error':'e'+str(N),'retry':True})
check('retry-id contract', solve('retry-id', {'command':'copy','attempt':N,'context':'doc'}), {'command':'copy','attempt':N+1,'context':'doc'})
check('completion contract', solve('completion', {'transaction':N,'pending':N+1}), 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 == 'prepare':
        return 'prepared' if p['validated'] and p['authorized'] else 'rejected'
    if action == 'pending':
        return p['state']=='prepared' and not p['inflight']
    if action == 'success-close':
        return p['success'] and p['policy']=='success'
    if action == 'failure':
        return {'state':'failed','error':p['error'],'retry':p['retryable']}
    if action == 'retry-id':
        return {'command':p['command'],'attempt':p['attempt']+1,'context':p['context']}
    if action == 'completion':
        return p['transaction']<=p['pending']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('prepare contract', solve('prepare', {'validated':True,'authorized':False,'command':N}), 'rejected')
check('pending contract', solve('pending', {'state':'prepared','inflight':True,'id':N}), False)
check('success-close contract', solve('success-close', {'success':False,'policy':'success','id':N}), False)
check('failure contract', solve('failure', {'error':'e'+str(N),'retryable':True}), {'state':'failed','error':'e'+str(N),'retry':True})
check('retry-id contract', solve('retry-id', {'command':'copy','attempt':N,'context':'doc'}), {'command':'copy','attempt':N+1,'context':'doc'})
check('completion contract', solve('completion', {'transaction':N,'pending':N+1}), 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:
Old menu command completion clears a newer pending action.

Menu command transactions have explicit preparation, execution, success and failure phases; close policy and duplicate suppression are separate.

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 == 'secondary':
        return p['button']==2
    if action == 'pen':
        return p['type']=='pen' and bool(p['buttons'] & 2)
    if action == 'hold':
        return p['elapsed']>=p['delay'] and p['travel']<=p['slop']
    if action == 'release':
        return p['armed'] and not p['cancelled']
    if action == 'duplicate':
        return p['incoming']!=p['last']
    if action == 'native-policy':
        return p['handled'] and p['custom_available']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('secondary contract', solve('secondary', {'button':2,'dragging':True,'distance':N}), False)
check('pen contract', solve('pen', {'type':'pen','buttons':3,'pressure':N/10}), True)
check('hold contract', solve('hold', {'elapsed':N+10,'delay':10,'travel':20,'slop':5}), False)
check('release contract', solve('release', {'armed':True,'cancelled':True,'id':N}), False)
check('duplicate contract', solve('duplicate', {'incoming':N,'last':N}), False)
check('native-policy contract', solve('native-policy', {'handled':True,'custom_available':False,'target':N}), False)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
check('ordinary pen contact', solve('pen', {'type':'pen','buttons':1,'pressure':N/10}), 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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'secondary':
        return p['button']!=0
    if action == 'pen':
        return p['type']=='pen' and bool(p['buttons'] & 2)
    if action == 'hold':
        return p['elapsed']>=p['delay'] and p['travel']<=p['slop']
    if action == 'release':
        return p['armed'] and not p['cancelled']
    if action == 'duplicate':
        return p['incoming']!=p['last']
    if action == 'native-policy':
        return p['handled'] and p['custom_available']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('secondary contract', solve('secondary', {'button':2,'dragging':True,'distance':N}), False)
check('pen contract', solve('pen', {'type':'pen','buttons':3,'pressure':N/10}), True)
check('hold contract', solve('hold', {'elapsed':N+10,'delay':10,'travel':20,'slop':5}), False)
check('release contract', solve('release', {'armed':True,'cancelled':True,'id':N}), False)
check('duplicate contract', solve('duplicate', {'incoming':N,'last':N}), False)
check('native-policy contract', solve('native-policy', {'handled':True,'custom_available':False,'target':N}), False)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
check('ordinary pen contact', solve('pen', {'type':'pen','buttons':1,'pressure':N/10}), 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:
Secondary drag termination unexpectedly opens a context menu.

A context menu recognizes secondary-button invocation, pen barrel input and completed hold gestures; concurrent triggers are coalesced by invocation identity.

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 == 'secondary':
        return p['button']==2 and not p['dragging']
    if action == 'pen':
        return p['type']=='pen'
    if action == 'hold':
        return p['elapsed']>=p['delay'] and p['travel']<=p['slop']
    if action == 'release':
        return p['armed'] and not p['cancelled']
    if action == 'duplicate':
        return p['incoming']!=p['last']
    if action == 'native-policy':
        return p['handled'] and p['custom_available']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('secondary contract', solve('secondary', {'button':2,'dragging':True,'distance':N}), False)
check('pen contract', solve('pen', {'type':'pen','buttons':3,'pressure':N/10}), True)
check('hold contract', solve('hold', {'elapsed':N+10,'delay':10,'travel':20,'slop':5}), False)
check('release contract', solve('release', {'armed':True,'cancelled':True,'id':N}), False)
check('duplicate contract', solve('duplicate', {'incoming':N,'last':N}), False)
check('native-policy contract', solve('native-policy', {'handled':True,'custom_available':False,'target':N}), False)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
check('ordinary pen contact', solve('pen', {'type':'pen','buttons':1,'pressure':N/10}), 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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'secondary':
        return p['button']==2 and not p['dragging']
    if action == 'pen':
        return p['type']=='pen' and p['buttons']==2
    if action == 'hold':
        return p['elapsed']>=p['delay'] and p['travel']<=p['slop']
    if action == 'release':
        return p['armed'] and not p['cancelled']
    if action == 'duplicate':
        return p['incoming']!=p['last']
    if action == 'native-policy':
        return p['handled'] and p['custom_available']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('secondary contract', solve('secondary', {'button':2,'dragging':True,'distance':N}), False)
check('pen contract', solve('pen', {'type':'pen','buttons':3,'pressure':N/10}), True)
check('hold contract', solve('hold', {'elapsed':N+10,'delay':10,'travel':20,'slop':5}), False)
check('release contract', solve('release', {'armed':True,'cancelled':True,'id':N}), False)
check('duplicate contract', solve('duplicate', {'incoming':N,'last':N}), False)
check('native-policy contract', solve('native-policy', {'handled':True,'custom_available':False,'target':N}), False)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
check('ordinary pen contact', solve('pen', {'type':'pen','buttons':1,'pressure':N/10}), 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:
Pen barrel context trigger rejects combined button state.

A context menu recognizes secondary-button invocation, pen barrel input and completed hold gestures; concurrent triggers are coalesced by invocation identity.

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 == 'secondary':
        return p['button']==2 and not p['dragging']
    if action == 'pen':
        return p['type']=='pen' and bool(p['buttons'] & 2)
    if action == 'hold':
        return p['elapsed']>=p['delay']
    if action == 'release':
        return p['armed'] and not p['cancelled']
    if action == 'duplicate':
        return p['incoming']!=p['last']
    if action == 'native-policy':
        return p['handled'] and p['custom_available']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('secondary contract', solve('secondary', {'button':2,'dragging':True,'distance':N}), False)
check('pen contract', solve('pen', {'type':'pen','buttons':3,'pressure':N/10}), True)
check('hold contract', solve('hold', {'elapsed':N+10,'delay':10,'travel':20,'slop':5}), False)
check('release contract', solve('release', {'armed':True,'cancelled':True,'id':N}), False)
check('duplicate contract', solve('duplicate', {'incoming':N,'last':N}), False)
check('native-policy contract', solve('native-policy', {'handled':True,'custom_available':False,'target':N}), False)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
check('ordinary pen contact', solve('pen', {'type':'pen','buttons':1,'pressure':N/10}), 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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'secondary':
        return p['button']==2 and not p['dragging']
    if action == 'pen':
        return p['type']=='pen' and bool(p['buttons'] & 2)
    if action == 'hold':
        return p['elapsed']>=p['delay'] or p['travel']<=p['slop']
    if action == 'release':
        return p['armed'] and not p['cancelled']
    if action == 'duplicate':
        return p['incoming']!=p['last']
    if action == 'native-policy':
        return p['handled'] and p['custom_available']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('secondary contract', solve('secondary', {'button':2,'dragging':True,'distance':N}), False)
check('pen contract', solve('pen', {'type':'pen','buttons':3,'pressure':N/10}), True)
check('hold contract', solve('hold', {'elapsed':N+10,'delay':10,'travel':20,'slop':5}), False)
check('release contract', solve('release', {'armed':True,'cancelled':True,'id':N}), False)
check('duplicate contract', solve('duplicate', {'incoming':N,'last':N}), False)
check('native-policy contract', solve('native-policy', {'handled':True,'custom_available':False,'target':N}), False)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
check('ordinary pen contact', solve('pen', {'type':'pen','buttons':1,'pressure':N/10}), 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:
Moved long press is still interpreted as a menu invocation.

A context menu recognizes secondary-button invocation, pen barrel input and completed hold gestures; concurrent triggers are coalesced by invocation identity.

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 == 'secondary':
        return p['button']==2 and not p['dragging']
    if action == 'pen':
        return p['type']=='pen' and bool(p['buttons'] & 2)
    if action == 'hold':
        return p['elapsed']>=p['delay'] and p['travel']<=p['slop']
    if action == 'release':
        return p['armed']
    if action == 'duplicate':
        return p['incoming']!=p['last']
    if action == 'native-policy':
        return p['handled'] and p['custom_available']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('secondary contract', solve('secondary', {'button':2,'dragging':True,'distance':N}), False)
check('pen contract', solve('pen', {'type':'pen','buttons':3,'pressure':N/10}), True)
check('hold contract', solve('hold', {'elapsed':N+10,'delay':10,'travel':20,'slop':5}), False)
check('release contract', solve('release', {'armed':True,'cancelled':True,'id':N}), False)
check('duplicate contract', solve('duplicate', {'incoming':N,'last':N}), False)
check('native-policy contract', solve('native-policy', {'handled':True,'custom_available':False,'target':N}), False)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
check('ordinary pen contact', solve('pen', {'type':'pen','buttons':1,'pressure':N/10}), 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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'secondary':
        return p['button']==2 and not p['dragging']
    if action == 'pen':
        return p['type']=='pen' and bool(p['buttons'] & 2)
    if action == 'hold':
        return p['elapsed']>=p['delay'] and p['travel']<=p['slop']
    if action == 'release':
        return p['armed'] or not p['cancelled']
    if action == 'duplicate':
        return p['incoming']!=p['last']
    if action == 'native-policy':
        return p['handled'] and p['custom_available']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('secondary contract', solve('secondary', {'button':2,'dragging':True,'distance':N}), False)
check('pen contract', solve('pen', {'type':'pen','buttons':3,'pressure':N/10}), True)
check('hold contract', solve('hold', {'elapsed':N+10,'delay':10,'travel':20,'slop':5}), False)
check('release contract', solve('release', {'armed':True,'cancelled':True,'id':N}), False)
check('duplicate contract', solve('duplicate', {'incoming':N,'last':N}), False)
check('native-policy contract', solve('native-policy', {'handled':True,'custom_available':False,'target':N}), False)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
check('ordinary pen contact', solve('pen', {'type':'pen','buttons':1,'pressure':N/10}), 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:
Cancelled context hold fires when the pointer is released.

A context menu recognizes secondary-button invocation, pen barrel input and completed hold gestures; concurrent triggers are coalesced by invocation identity.

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 == 'secondary':
        return p['button']==2 and not p['dragging']
    if action == 'pen':
        return p['type']=='pen' and bool(p['buttons'] & 2)
    if action == 'hold':
        return p['elapsed']>=p['delay'] and p['travel']<=p['slop']
    if action == 'release':
        return p['armed'] and not p['cancelled']
    if action == 'duplicate':
        return True
    if action == 'native-policy':
        return p['handled'] and p['custom_available']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('secondary contract', solve('secondary', {'button':2,'dragging':True,'distance':N}), False)
check('pen contract', solve('pen', {'type':'pen','buttons':3,'pressure':N/10}), True)
check('hold contract', solve('hold', {'elapsed':N+10,'delay':10,'travel':20,'slop':5}), False)
check('release contract', solve('release', {'armed':True,'cancelled':True,'id':N}), False)
check('duplicate contract', solve('duplicate', {'incoming':N,'last':N}), False)
check('native-policy contract', solve('native-policy', {'handled':True,'custom_available':False,'target':N}), False)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
check('ordinary pen contact', solve('pen', {'type':'pen','buttons':1,'pressure':N/10}), 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
import math
import unicodedata
N = 1
observations = []
def solve(action, p):
    if action == 'secondary':
        return p['button']==2 and not p['dragging']
    if action == 'pen':
        return p['type']=='pen' and bool(p['buttons'] & 2)
    if action == 'hold':
        return p['elapsed']>=p['delay'] and p['travel']<=p['slop']
    if action == 'release':
        return p['armed'] and not p['cancelled']
    if action == 'duplicate':
        return p['incoming']>=p['last']
    if action == 'native-policy':
        return p['handled'] and p['custom_available']
    return {'error': 'unsupported menu operation'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('secondary contract', solve('secondary', {'button':2,'dragging':True,'distance':N}), False)
check('pen contract', solve('pen', {'type':'pen','buttons':3,'pressure':N/10}), True)
check('hold contract', solve('hold', {'elapsed':N+10,'delay':10,'travel':20,'slop':5}), False)
check('release contract', solve('release', {'armed':True,'cancelled':True,'id':N}), False)
check('duplicate contract', solve('duplicate', {'incoming':N,'last':N}), False)
check('native-policy contract', solve('native-policy', {'handled':True,'custom_available':False,'target':N}), False)
check('unknown operation', solve('unknown', {}), {'error': 'unsupported menu operation'})
check('ordinary pen contact', solve('pen', {'type':'pen','buttons':1,'pressure':N/10}), 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:
Native and synthetic context events open duplicate popups.

A context menu recognizes secondary-button invocation, pen barrel input and completed hold gestures; concurrent triggers are coalesced by invocation identity.

split: open-access