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

N = 1
observations = []
def solve(d):
    errors=[]
    if len(d['params'])!=len(set(d['params'])): errors.append('duplicate-param')
    if any(x not in d['params'] and x!='static' for x in d['uses']): errors.append('undeclared-occurrence')
    if d['elided'] and d['receiver'] is None and len(set(d['inputs']))!=1: errors.append('ambiguous-elision')
    if d['elided'] and d['receiver'] is not None and d['output']!=d['receiver']: errors.append('receiver-elision')
    if any(x not in d['inputs'] for x in d['sources']): errors.append('output-source')
    if bool(set(d['sources'])&set(d['locals'])): errors.append('local-return')
    if d['mutable_out'] and not set(d['sources'])<=set(d['mutable_inputs']): errors.append('mutable-source')
    if not set(d['required'])<=set(d['available']): errors.append('return-extent')
    if d['bound_depth']>d['output_depth']: errors.append('binder-escape')
    if False: errors.append('unused-param')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'params': ['a'], 'uses': ['a'], 'inputs': ['a'], 'output': None, 'receiver': None, 'elided': False, 'sources': [], 'locals': [], 'mutable_out': False, 'mutable_inputs': [], 'required': [], 'available': [], 'bound_depth': 0, 'output_depth': 0, 'used_params': ['a']}
check('well formed empty obligations',solve(base),[])
check('duplicate-param regression 0', solve(dict(base, **({'params':['a','a']}))), ['duplicate-param'])
check('duplicate-param regression 1', solve(dict(base, **({'params':['a','a']}))), ['duplicate-param'])
check('undeclared-occurrence regression 0', solve(dict(base, **({'uses':['a','b'+str(N)]}))), ['undeclared-occurrence'])
check('undeclared-occurrence regression 1', solve(dict(base, **({'uses':['a','z']}))), ['undeclared-occurrence'])
check('ambiguous-elision regression 0', solve(dict(base, **({'elided':True,'inputs':['a','b']}))), ['ambiguous-elision'])
check('ambiguous-elision regression 1', solve(dict(base, **({'elided':True,'inputs':list(range(N+2))}))), ['ambiguous-elision'])
check('receiver-elision regression 0', solve(dict(base, **({'elided':True,'receiver':'a','output':'b'}))), ['receiver-elision'])
check('receiver-elision regression 1', solve(dict(base, **({'elided':True,'receiver':'a','output':'static'}))), ['receiver-elision'])
check('output-source regression 0', solve(dict(base, **({'sources':['a','b']}))), ['output-source'])
check('output-source regression 1', solve(dict(base, **({'sources':['a','z'+str(N)]}))), ['output-source'])
check('local-return regression 0', solve(dict(base, **({'inputs':['a','b'],'sources':['a','b'],'locals':['b']}))), ['local-return'])
check('local-return regression 1', solve(dict(base, **({'inputs':['a','c'],'sources':['a','c'],'locals':['c']}))), ['local-return'])
check('mutable-source regression 0', solve(dict(base, **({'mutable_out':True,'inputs':['a','b'],'sources':['a','b'],'mutable_inputs':['a']}))), ['mutable-source'])
check('mutable-source regression 1', solve(dict(base, **({'mutable_out':True,'sources':['a'],'mutable_inputs':['b']}))), ['mutable-source'])
check('return-extent regression 0', solve(dict(base, **({'required':[N],'available':[N+1]}))), ['return-extent'])
check('return-extent regression 1', solve(dict(base, **({'required':[N,N+1],'available':[N+1,N+2]}))), ['return-extent'])
check('binder-escape regression 0', solve(dict(base, **({'bound_depth':N,'output_depth':N-1}))), ['binder-escape'])
check('binder-escape regression 1', solve(dict(base, **({'bound_depth':N+1,'output_depth':N}))), ['binder-escape'])
check('unused-param regression 0', solve(dict(base, **({'params':['a','b'],'used_params':['a']}))), ['unused-param'])
check('unused-param regression 1', solve(dict(base, **({'params':['a','z'+str(N)],'used_params':['a']}))), ['unused-param'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    errors=[]
    if len(d['params'])!=len(set(d['params'])): errors.append('duplicate-param')
    if any(x not in d['params'] and x!='static' for x in d['uses']): errors.append('undeclared-occurrence')
    if d['elided'] and d['receiver'] is None and len(set(d['inputs']))!=1: errors.append('ambiguous-elision')
    if d['elided'] and d['receiver'] is not None and d['output']!=d['receiver']: errors.append('receiver-elision')
    if any(x not in d['inputs'] for x in d['sources']): errors.append('output-source')
    if bool(set(d['sources'])&set(d['locals'])): errors.append('local-return')
    if d['mutable_out'] and not set(d['sources'])<=set(d['mutable_inputs']): errors.append('mutable-source')
    if not set(d['required'])<=set(d['available']): errors.append('return-extent')
    if d['bound_depth']>d['output_depth']: errors.append('binder-escape')
    if not d['used_params']: errors.append('unused-param')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'params': ['a'], 'uses': ['a'], 'inputs': ['a'], 'output': None, 'receiver': None, 'elided': False, 'sources': [], 'locals': [], 'mutable_out': False, 'mutable_inputs': [], 'required': [], 'available': [], 'bound_depth': 0, 'output_depth': 0, 'used_params': ['a']}
check('well formed empty obligations',solve(base),[])
check('duplicate-param regression 0', solve(dict(base, **({'params':['a','a']}))), ['duplicate-param'])
check('duplicate-param regression 1', solve(dict(base, **({'params':['a','a']}))), ['duplicate-param'])
check('undeclared-occurrence regression 0', solve(dict(base, **({'uses':['a','b'+str(N)]}))), ['undeclared-occurrence'])
check('undeclared-occurrence regression 1', solve(dict(base, **({'uses':['a','z']}))), ['undeclared-occurrence'])
check('ambiguous-elision regression 0', solve(dict(base, **({'elided':True,'inputs':['a','b']}))), ['ambiguous-elision'])
check('ambiguous-elision regression 1', solve(dict(base, **({'elided':True,'inputs':list(range(N+2))}))), ['ambiguous-elision'])
check('receiver-elision regression 0', solve(dict(base, **({'elided':True,'receiver':'a','output':'b'}))), ['receiver-elision'])
check('receiver-elision regression 1', solve(dict(base, **({'elided':True,'receiver':'a','output':'static'}))), ['receiver-elision'])
check('output-source regression 0', solve(dict(base, **({'sources':['a','b']}))), ['output-source'])
check('output-source regression 1', solve(dict(base, **({'sources':['a','z'+str(N)]}))), ['output-source'])
check('local-return regression 0', solve(dict(base, **({'inputs':['a','b'],'sources':['a','b'],'locals':['b']}))), ['local-return'])
check('local-return regression 1', solve(dict(base, **({'inputs':['a','c'],'sources':['a','c'],'locals':['c']}))), ['local-return'])
check('mutable-source regression 0', solve(dict(base, **({'mutable_out':True,'inputs':['a','b'],'sources':['a','b'],'mutable_inputs':['a']}))), ['mutable-source'])
check('mutable-source regression 1', solve(dict(base, **({'mutable_out':True,'sources':['a'],'mutable_inputs':['b']}))), ['mutable-source'])
check('return-extent regression 0', solve(dict(base, **({'required':[N],'available':[N+1]}))), ['return-extent'])
check('return-extent regression 1', solve(dict(base, **({'required':[N,N+1],'available':[N+1,N+2]}))), ['return-extent'])
check('binder-escape regression 0', solve(dict(base, **({'bound_depth':N,'output_depth':N-1}))), ['binder-escape'])
check('binder-escape regression 1', solve(dict(base, **({'bound_depth':N+1,'output_depth':N}))), ['binder-escape'])
check('unused-param regression 0', solve(dict(base, **({'params':['a','b'],'used_params':['a']}))), ['unused-param'])
check('unused-param regression 1', solve(dict(base, **({'params':['a','z'+str(N)],'used_params':['a']}))), ['unused-param'])
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:
An unused lifetime parameter survives when another parameter is used.

Check borrowed function signature well-formedness: lifetime parameters unique; all occurrences declared or static; output elision needs exactly one input lifetime; receiver elision uses receiver lifetime; every output source is an input; by-reference return cannot originate in a local; returned mutable borrow requires mutable input; output extent must fit source extent; bound lifetime cannot escape binder depth; unused lifetime parameters rejected in this toy language. Input is a fully explicit descriptor of the stated toy IR. Return rule identifiers in declaration order; absent optional obligations use the provided neutral defaults. No rule is an assertion about a production language.

split: open-access


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

N = 1
observations = []
def solve(d):
    errors=[]
    if False: errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(d):
    errors=[]
    if bool(d['captures']) and d['captures'][0] not in d['declared']: errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
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:
Capture inference forgets to resolve later captured places.

Validate an inferred closure environment. Captures contain declared places; overlapping prefix captures must be minimized; unique captures may not be duplicated; consumed captures require Once call mode; mutated captures require Mut or Once; an escaping environment cannot hold stack-only origins; environment region contains all call sites; captured references remain valid for the environment region; captures of packed fields cannot form references; captures of destructor-bearing aggregates cannot be narrowed to moved fields. Input is a fully explicit descriptor of the stated toy IR. Return rule identifiers in declaration order; absent optional obligations use the provided neutral defaults. No rule is an assertion about a production language.

split: open-access


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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if False: errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b==a+'.x' for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
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:
Ancestor capture does not subsume a nested captured place.

Validate an inferred closure environment. Captures contain declared places; overlapping prefix captures must be minimized; unique captures may not be duplicated; consumed captures require Once call mode; mutated captures require Mut or Once; an escaping environment cannot hold stack-only origins; environment region contains all call sites; captured references remain valid for the environment region; captures of packed fields cannot form references; captures of destructor-bearing aggregates cannot be narrowed to moved fields. Input is a fully explicit descriptor of the stated toy IR. Return rule identifiers in declaration order; absent optional obligations use the provided neutral defaults. No rule is an assertion about a production language.

split: open-access


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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if False: errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])>2 and len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
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 unique capture is duplicated while constructing the environment.

Validate an inferred closure environment. Captures contain declared places; overlapping prefix captures must be minimized; unique captures may not be duplicated; consumed captures require Once call mode; mutated captures require Mut or Once; an escaping environment cannot hold stack-only origins; environment region contains all call sites; captured references remain valid for the environment region; captures of packed fields cannot form references; captures of destructor-bearing aggregates cannot be narrowed to moved fields. Input is a fully explicit descriptor of the stated toy IR. Return rule identifiers in declaration order; absent optional obligations use the provided neutral defaults. No rule is an assertion about a production language.

split: open-access


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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if False: errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']=='Shared': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
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 consuming closure is incorrectly admitted as repeatedly mutable-callable.

Validate an inferred closure environment. Captures contain declared places; overlapping prefix captures must be minimized; unique captures may not be duplicated; consumed captures require Once call mode; mutated captures require Mut or Once; an escaping environment cannot hold stack-only origins; environment region contains all call sites; captured references remain valid for the environment region; captures of packed fields cannot form references; captures of destructor-bearing aggregates cannot be narrowed to moved fields. Input is a fully explicit descriptor of the stated toy IR. Return rule identifiers in declaration order; absent optional obligations use the provided neutral defaults. No rule is an assertion about a production language.

split: open-access


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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if False: errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if len(d['mutated'])>1 and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
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 single mutated capture fails to upgrade closure call capability.

Validate an inferred closure environment. Captures contain declared places; overlapping prefix captures must be minimized; unique captures may not be duplicated; consumed captures require Once call mode; mutated captures require Mut or Once; an escaping environment cannot hold stack-only origins; environment region contains all call sites; captured references remain valid for the environment region; captures of packed fields cannot form references; captures of destructor-bearing aggregates cannot be narrowed to moved fields. Input is a fully explicit descriptor of the stated toy IR. Return rule identifiers in declaration order; absent optional obligations use the provided neutral defaults. No rule is an assertion about a production language.

split: open-access


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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if False: errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(d['captures']) and d['captures'][0] in d['stack']: errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
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 later captured stack reference escapes with the closure environment.

Validate an inferred closure environment. Captures contain declared places; overlapping prefix captures must be minimized; unique captures may not be duplicated; consumed captures require Once call mode; mutated captures require Mut or Once; an escaping environment cannot hold stack-only origins; environment region contains all call sites; captured references remain valid for the environment region; captures of packed fields cannot form references; captures of destructor-bearing aggregates cannot be narrowed to moved fields. Input is a fully explicit descriptor of the stated toy IR. Return rule identifiers in declaration order; absent optional obligations use the provided neutral defaults. No rule is an assertion about a production language.

split: open-access


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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if False: errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if len(d['calls'])>len(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
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:
Closure call sites extend beyond inferred environment lifetime.

Validate an inferred closure environment. Captures contain declared places; overlapping prefix captures must be minimized; unique captures may not be duplicated; consumed captures require Once call mode; mutated captures require Mut or Once; an escaping environment cannot hold stack-only origins; environment region contains all call sites; captured references remain valid for the environment region; captures of packed fields cannot form references; captures of destructor-bearing aggregates cannot be narrowed to moved fields. Input is a fully explicit descriptor of the stated toy IR. Return rule identifiers in declaration order; absent optional obligations use the provided neutral defaults. No rule is an assertion about a production language.

split: open-access


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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if False: errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not d['valid'] and bool(d['env']): errors.append('capture-validity')
    if bool(set(d['captures'])&set(d['packed'])): errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
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:
An environment outlives the storage of a captured reference.

Validate an inferred closure environment. Captures contain declared places; overlapping prefix captures must be minimized; unique captures may not be duplicated; consumed captures require Once call mode; mutated captures require Mut or Once; an escaping environment cannot hold stack-only origins; environment region contains all call sites; captured references remain valid for the environment region; captures of packed fields cannot form references; captures of destructor-bearing aggregates cannot be narrowed to moved fields. Input is a fully explicit descriptor of the stated toy IR. Return rule identifiers in declaration order; absent optional obligations use the provided neutral defaults. No rule is an assertion about a production language.

split: open-access


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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if False: errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    errors=[]
    if not set(d['captures'])<=set(d['declared']): errors.append('capture-declaration')
    if any(a!=b and b.startswith(a+'.') for a in d['captures'] for b in d['captures']): errors.append('capture-prefix')
    if len(d['unique'])!=len(set(d['unique'])): errors.append('unique-duplicate')
    if bool(d['consumed']) and d['mode']!='Once': errors.append('once-mode')
    if bool(d['mutated']) and d['mode']=='Shared': errors.append('mut-mode')
    if d['escapes'] and bool(set(d['captures'])&set(d['stack'])): errors.append('escape-stack')
    if not set(d['calls'])<=set(d['env']): errors.append('call-region')
    if not set(d['env'])<=set(d['valid']): errors.append('capture-validity')
    if bool(d['captures']) and d['captures'][0] in d['packed']: errors.append('packed-reference')
    if any(p.split('.')[0] in d['drop_aggregates'] for p in d['narrow_moves']): errors.append('destructor-narrowing')
    return errors
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
base={'captures': [], 'declared': [], 'unique': [], 'consumed': [], 'mutated': [], 'mode': 'Shared', 'escapes': False, 'stack': [], 'env': [], 'calls': [], 'valid': [], 'packed': [], 'narrow_moves': [], 'drop_aggregates': []}
check('well formed empty obligations',solve(base),[])
check('capture-declaration regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a']}))), ['capture-declaration'])
check('capture-declaration regression 1', solve(dict(base, **({'captures':['a','x'+str(N)],'declared':['a']}))), ['capture-declaration'])
check('capture-prefix regression 0', solve(dict(base, **({'captures':['r','r.y'],'declared':['r','r.y']}))), ['capture-prefix'])
check('capture-prefix regression 1', solve(dict(base, **({'captures':['r','r.y.z'],'declared':['r','r.y.z']}))), ['capture-prefix'])
check('unique-duplicate regression 0', solve(dict(base, **({'unique':['r','r']}))), ['unique-duplicate'])
check('unique-duplicate regression 1', solve(dict(base, **({'unique':[N,N]}))), ['unique-duplicate'])
check('once-mode regression 0', solve(dict(base, **({'consumed':['x'],'mode':'Mut'}))), ['once-mode'])
check('once-mode regression 1', solve(dict(base, **({'consumed':list(range(N)),'mode':'Mut'}))), ['once-mode'])
check('mut-mode regression 0', solve(dict(base, **({'mutated':['x']}))), ['mut-mode'])
check('mut-mode regression 1', solve(dict(base, **({'mutated':[N]}))), ['mut-mode'])
check('escape-stack regression 0', solve(dict(base, **({'escapes':True,'captures':['a','b'],'declared':['a','b'],'stack':['b']}))), ['escape-stack'])
check('escape-stack regression 1', solve(dict(base, **({'escapes':True,'captures':['a','c'],'declared':['a','c'],'stack':['c']}))), ['escape-stack'])
check('call-region regression 0', solve(dict(base, **({'calls':[N],'env':[N+1],'valid':[N+1]}))), ['call-region'])
check('call-region regression 1', solve(dict(base, **({'calls':[N,N+1],'env':[N+1,N+2],'valid':[N+1,N+2]}))), ['call-region'])
check('capture-validity regression 0', solve(dict(base, **({'env':[N,N+1],'valid':[N]}))), ['capture-validity'])
check('capture-validity regression 1', solve(dict(base, **({'env':[N],'valid':[N+1]}))), ['capture-validity'])
check('packed-reference regression 0', solve(dict(base, **({'captures':['a','b'],'declared':['a','b'],'packed':['b']}))), ['packed-reference'])
check('packed-reference regression 1', solve(dict(base, **({'captures':['a','c'],'declared':['a','c'],'packed':['c']}))), ['packed-reference'])
check('destructor-narrowing regression 0', solve(dict(base, **({'narrow_moves':['r.f'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
check('destructor-narrowing regression 1', solve(dict(base, **({'narrow_moves':['r.f.g'],'drop_aggregates':['r']}))), ['destructor-narrowing'])
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 packed captured field is borrowed as though it were aligned.

Validate an inferred closure environment. Captures contain declared places; overlapping prefix captures must be minimized; unique captures may not be duplicated; consumed captures require Once call mode; mutated captures require Mut or Once; an escaping environment cannot hold stack-only origins; environment region contains all call sites; captured references remain valid for the environment region; captures of packed fields cannot form references; captures of destructor-bearing aggregates cannot be narrowed to moved fields. Input is a fully explicit descriptor of the stated toy IR. Return rule identifiers in declaration order; absent optional obligations use the provided neutral defaults. No rule is an assertion about a production language.

split: open-access