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

N = 1
observations = []
def solve(operation, s):
    defaults, device, workspace, session, locked, removed = s
    if operation == 'layer-precedence':
        return {**defaults,**device,**workspace,**session}
    if operation == 'locked-workspace-values':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in locked}}
    if operation == 'session-only-reset':
        return {**defaults,**device,**workspace}
    if operation == 'device-layer-serialization':
        return dict(device)
    if operation == 'explicit-session-keys':
        return list(session)
    if operation == 'session-key-removal-falls-through':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in removed}}
    if operation == 'writable-preference-projection':
        return session
    if operation == 'preference-source-attribution':
        return {k:next(layer for layer,values in [('session',session),('workspace',workspace),('device',device),('default',defaults)] if k in values) for k in sorted(set(defaults)|set(device)|set(workspace)|set(session))}
    if operation == 'redundant-device-override-pruning':
        return {k:v for k,v in device.items() if k not in defaults or defaults[k]!=v}
    if operation == 'workspace-lock-report':
        return [k for k in locked if k in workspace]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layer-precedence scenario 1', solve('layer-precedence', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('layer-precedence scenario 2', solve('layer-precedence', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('layer-precedence scenario 3', solve('layer-precedence', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':4})
check('layer-precedence scenario 4', solve('layer-precedence', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('layer-precedence scenario 5', solve('layer-precedence', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('layer-precedence scenario 6', solve('layer-precedence', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('locked-workspace-values scenario 1', solve('locked-workspace-values', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('locked-workspace-values scenario 2', solve('locked-workspace-values', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('locked-workspace-values scenario 3', solve('locked-workspace-values', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('locked-workspace-values scenario 4', solve('locked-workspace-values', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('locked-workspace-values scenario 5', solve('locked-workspace-values', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('locked-workspace-values scenario 6', solve('locked-workspace-values', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('session-only-reset scenario 1', solve('session-only-reset', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark','size':N})
check('session-only-reset scenario 2', solve('session-only-reset', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-only-reset scenario 3', solve('session-only-reset', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-only-reset scenario 4', solve('session-only-reset', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-only-reset scenario 5', solve('session-only-reset', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-only-reset scenario 6', solve('session-only-reset', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':3})
check('device-layer-serialization scenario 1', solve('device-layer-serialization', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('device-layer-serialization scenario 2', solve('device-layer-serialization', ({'theme':'light'}, {},{}, {},[],[])), {})
check('device-layer-serialization scenario 3', solve('device-layer-serialization', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('device-layer-serialization scenario 4', solve('device-layer-serialization', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('device-layer-serialization scenario 5', solve('device-layer-serialization', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('device-layer-serialization scenario 6', solve('device-layer-serialization', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('explicit-session-keys scenario 1', solve('explicit-session-keys', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['theme'])
check('explicit-session-keys scenario 2', solve('explicit-session-keys', ({'theme':'light'}, {},{}, {},[],[])), [])
check('explicit-session-keys scenario 3', solve('explicit-session-keys', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('explicit-session-keys scenario 4', solve('explicit-session-keys', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('explicit-session-keys scenario 5', solve('explicit-session-keys', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), ['theme'])
check('explicit-session-keys scenario 6', solve('explicit-session-keys', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), ['size'])
check('session-key-removal-falls-through scenario 1', solve('session-key-removal-falls-through', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('session-key-removal-falls-through scenario 2', solve('session-key-removal-falls-through', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-key-removal-falls-through scenario 3', solve('session-key-removal-falls-through', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-key-removal-falls-through scenario 4', solve('session-key-removal-falls-through', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-key-removal-falls-through scenario 5', solve('session-key-removal-falls-through', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-key-removal-falls-through scenario 6', solve('session-key-removal-falls-through', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('writable-preference-projection scenario 1', solve('writable-preference-projection', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':''})
check('writable-preference-projection scenario 2', solve('writable-preference-projection', ({'theme':'light'}, {},{}, {},[],[])), {})
check('writable-preference-projection scenario 3', solve('writable-preference-projection', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {})
check('writable-preference-projection scenario 4', solve('writable-preference-projection', ({'theme':'light'},{'theme':None},{},{},[],[])), {})
check('writable-preference-projection scenario 5', solve('writable-preference-projection', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('writable-preference-projection scenario 6', solve('writable-preference-projection', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('preference-source-attribution scenario 1', solve('preference-source-attribution', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'size':'workspace','theme':'session'})
check('preference-source-attribution scenario 2', solve('preference-source-attribution', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'default'})
check('preference-source-attribution scenario 3', solve('preference-source-attribution', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':'session'})
check('preference-source-attribution scenario 4', solve('preference-source-attribution', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':'device'})
check('preference-source-attribution scenario 5', solve('preference-source-attribution', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'session'})
check('preference-source-attribution scenario 6', solve('preference-source-attribution', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':'session'})
check('redundant-device-override-pruning scenario 1', solve('redundant-device-override-pruning', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 2', solve('redundant-device-override-pruning', ({'theme':'light'}, {},{}, {},[],[])), {})
check('redundant-device-override-pruning scenario 3', solve('redundant-device-override-pruning', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('redundant-device-override-pruning scenario 4', solve('redundant-device-override-pruning', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('redundant-device-override-pruning scenario 5', solve('redundant-device-override-pruning', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 6', solve('redundant-device-override-pruning', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('workspace-lock-report scenario 1', solve('workspace-lock-report', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['size'])
check('workspace-lock-report scenario 2', solve('workspace-lock-report', ({'theme':'light'}, {},{}, {},[],[])), [])
check('workspace-lock-report scenario 3', solve('workspace-lock-report', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('workspace-lock-report scenario 4', solve('workspace-lock-report', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('workspace-lock-report scenario 5', solve('workspace-lock-report', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), [])
check('workspace-lock-report scenario 6', solve('workspace-lock-report', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), [])
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(operation, s):
    defaults, device, workspace, session, locked, removed = s
    if operation == 'layer-precedence':
        return {**defaults,**device,**workspace,**session}
    if operation == 'locked-workspace-values':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in locked}}
    if operation == 'session-only-reset':
        return {**defaults,**device,**workspace}
    if operation == 'device-layer-serialization':
        return dict(device)
    if operation == 'explicit-session-keys':
        return list(session)
    if operation == 'session-key-removal-falls-through':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in removed}}
    if operation == 'writable-preference-projection':
        return {k:v for k,v in session.items() if k in locked}
    if operation == 'preference-source-attribution':
        return {k:next(layer for layer,values in [('session',session),('workspace',workspace),('device',device),('default',defaults)] if k in values) for k in sorted(set(defaults)|set(device)|set(workspace)|set(session))}
    if operation == 'redundant-device-override-pruning':
        return {k:v for k,v in device.items() if k not in defaults or defaults[k]!=v}
    if operation == 'workspace-lock-report':
        return [k for k in locked if k in workspace]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layer-precedence scenario 1', solve('layer-precedence', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('layer-precedence scenario 2', solve('layer-precedence', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('layer-precedence scenario 3', solve('layer-precedence', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':4})
check('layer-precedence scenario 4', solve('layer-precedence', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('layer-precedence scenario 5', solve('layer-precedence', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('layer-precedence scenario 6', solve('layer-precedence', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('locked-workspace-values scenario 1', solve('locked-workspace-values', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('locked-workspace-values scenario 2', solve('locked-workspace-values', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('locked-workspace-values scenario 3', solve('locked-workspace-values', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('locked-workspace-values scenario 4', solve('locked-workspace-values', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('locked-workspace-values scenario 5', solve('locked-workspace-values', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('locked-workspace-values scenario 6', solve('locked-workspace-values', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('session-only-reset scenario 1', solve('session-only-reset', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark','size':N})
check('session-only-reset scenario 2', solve('session-only-reset', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-only-reset scenario 3', solve('session-only-reset', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-only-reset scenario 4', solve('session-only-reset', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-only-reset scenario 5', solve('session-only-reset', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-only-reset scenario 6', solve('session-only-reset', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':3})
check('device-layer-serialization scenario 1', solve('device-layer-serialization', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('device-layer-serialization scenario 2', solve('device-layer-serialization', ({'theme':'light'}, {},{}, {},[],[])), {})
check('device-layer-serialization scenario 3', solve('device-layer-serialization', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('device-layer-serialization scenario 4', solve('device-layer-serialization', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('device-layer-serialization scenario 5', solve('device-layer-serialization', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('device-layer-serialization scenario 6', solve('device-layer-serialization', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('explicit-session-keys scenario 1', solve('explicit-session-keys', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['theme'])
check('explicit-session-keys scenario 2', solve('explicit-session-keys', ({'theme':'light'}, {},{}, {},[],[])), [])
check('explicit-session-keys scenario 3', solve('explicit-session-keys', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('explicit-session-keys scenario 4', solve('explicit-session-keys', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('explicit-session-keys scenario 5', solve('explicit-session-keys', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), ['theme'])
check('explicit-session-keys scenario 6', solve('explicit-session-keys', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), ['size'])
check('session-key-removal-falls-through scenario 1', solve('session-key-removal-falls-through', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('session-key-removal-falls-through scenario 2', solve('session-key-removal-falls-through', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-key-removal-falls-through scenario 3', solve('session-key-removal-falls-through', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-key-removal-falls-through scenario 4', solve('session-key-removal-falls-through', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-key-removal-falls-through scenario 5', solve('session-key-removal-falls-through', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-key-removal-falls-through scenario 6', solve('session-key-removal-falls-through', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('writable-preference-projection scenario 1', solve('writable-preference-projection', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':''})
check('writable-preference-projection scenario 2', solve('writable-preference-projection', ({'theme':'light'}, {},{}, {},[],[])), {})
check('writable-preference-projection scenario 3', solve('writable-preference-projection', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {})
check('writable-preference-projection scenario 4', solve('writable-preference-projection', ({'theme':'light'},{'theme':None},{},{},[],[])), {})
check('writable-preference-projection scenario 5', solve('writable-preference-projection', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('writable-preference-projection scenario 6', solve('writable-preference-projection', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('preference-source-attribution scenario 1', solve('preference-source-attribution', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'size':'workspace','theme':'session'})
check('preference-source-attribution scenario 2', solve('preference-source-attribution', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'default'})
check('preference-source-attribution scenario 3', solve('preference-source-attribution', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':'session'})
check('preference-source-attribution scenario 4', solve('preference-source-attribution', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':'device'})
check('preference-source-attribution scenario 5', solve('preference-source-attribution', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'session'})
check('preference-source-attribution scenario 6', solve('preference-source-attribution', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':'session'})
check('redundant-device-override-pruning scenario 1', solve('redundant-device-override-pruning', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 2', solve('redundant-device-override-pruning', ({'theme':'light'}, {},{}, {},[],[])), {})
check('redundant-device-override-pruning scenario 3', solve('redundant-device-override-pruning', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('redundant-device-override-pruning scenario 4', solve('redundant-device-override-pruning', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('redundant-device-override-pruning scenario 5', solve('redundant-device-override-pruning', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 6', solve('redundant-device-override-pruning', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('workspace-lock-report scenario 1', solve('workspace-lock-report', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['size'])
check('workspace-lock-report scenario 2', solve('workspace-lock-report', ({'theme':'light'}, {},{}, {},[],[])), [])
check('workspace-lock-report scenario 3', solve('workspace-lock-report', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('workspace-lock-report scenario 4', solve('workspace-lock-report', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('workspace-lock-report scenario 5', solve('workspace-lock-report', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), [])
check('workspace-lock-report scenario 6', solve('workspace-lock-report', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), [])
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:
Writable preference projection.

Client preferences overlay defaults, device, workspace and session in that order. Workspace locks exclude session writes. Removing an override reveals the lower layer; serialization preserves its own layer and explicit null/falsy values. Operation writable-preference-projection has the six explicit input/output oracles below.

split: open-access


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

N = 1
observations = []
def solve(operation, s):
    defaults, device, workspace, session, locked, removed = s
    if operation == 'layer-precedence':
        return {**defaults,**device,**workspace,**session}
    if operation == 'locked-workspace-values':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in locked}}
    if operation == 'session-only-reset':
        return {**defaults,**device,**workspace}
    if operation == 'device-layer-serialization':
        return dict(device)
    if operation == 'explicit-session-keys':
        return list(session)
    if operation == 'session-key-removal-falls-through':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in removed}}
    if operation == 'writable-preference-projection':
        return {k:v for k,v in session.items() if k not in locked}
    if operation == 'preference-source-attribution':
        return {k:'session' for k in sorted(set(defaults)|set(device)|set(workspace)|set(session))}
    if operation == 'redundant-device-override-pruning':
        return {k:v for k,v in device.items() if k not in defaults or defaults[k]!=v}
    if operation == 'workspace-lock-report':
        return [k for k in locked if k in workspace]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layer-precedence scenario 1', solve('layer-precedence', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('layer-precedence scenario 2', solve('layer-precedence', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('layer-precedence scenario 3', solve('layer-precedence', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':4})
check('layer-precedence scenario 4', solve('layer-precedence', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('layer-precedence scenario 5', solve('layer-precedence', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('layer-precedence scenario 6', solve('layer-precedence', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('locked-workspace-values scenario 1', solve('locked-workspace-values', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('locked-workspace-values scenario 2', solve('locked-workspace-values', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('locked-workspace-values scenario 3', solve('locked-workspace-values', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('locked-workspace-values scenario 4', solve('locked-workspace-values', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('locked-workspace-values scenario 5', solve('locked-workspace-values', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('locked-workspace-values scenario 6', solve('locked-workspace-values', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('session-only-reset scenario 1', solve('session-only-reset', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark','size':N})
check('session-only-reset scenario 2', solve('session-only-reset', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-only-reset scenario 3', solve('session-only-reset', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-only-reset scenario 4', solve('session-only-reset', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-only-reset scenario 5', solve('session-only-reset', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-only-reset scenario 6', solve('session-only-reset', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':3})
check('device-layer-serialization scenario 1', solve('device-layer-serialization', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('device-layer-serialization scenario 2', solve('device-layer-serialization', ({'theme':'light'}, {},{}, {},[],[])), {})
check('device-layer-serialization scenario 3', solve('device-layer-serialization', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('device-layer-serialization scenario 4', solve('device-layer-serialization', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('device-layer-serialization scenario 5', solve('device-layer-serialization', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('device-layer-serialization scenario 6', solve('device-layer-serialization', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('explicit-session-keys scenario 1', solve('explicit-session-keys', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['theme'])
check('explicit-session-keys scenario 2', solve('explicit-session-keys', ({'theme':'light'}, {},{}, {},[],[])), [])
check('explicit-session-keys scenario 3', solve('explicit-session-keys', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('explicit-session-keys scenario 4', solve('explicit-session-keys', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('explicit-session-keys scenario 5', solve('explicit-session-keys', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), ['theme'])
check('explicit-session-keys scenario 6', solve('explicit-session-keys', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), ['size'])
check('session-key-removal-falls-through scenario 1', solve('session-key-removal-falls-through', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('session-key-removal-falls-through scenario 2', solve('session-key-removal-falls-through', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-key-removal-falls-through scenario 3', solve('session-key-removal-falls-through', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-key-removal-falls-through scenario 4', solve('session-key-removal-falls-through', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-key-removal-falls-through scenario 5', solve('session-key-removal-falls-through', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-key-removal-falls-through scenario 6', solve('session-key-removal-falls-through', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('writable-preference-projection scenario 1', solve('writable-preference-projection', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':''})
check('writable-preference-projection scenario 2', solve('writable-preference-projection', ({'theme':'light'}, {},{}, {},[],[])), {})
check('writable-preference-projection scenario 3', solve('writable-preference-projection', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {})
check('writable-preference-projection scenario 4', solve('writable-preference-projection', ({'theme':'light'},{'theme':None},{},{},[],[])), {})
check('writable-preference-projection scenario 5', solve('writable-preference-projection', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('writable-preference-projection scenario 6', solve('writable-preference-projection', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('preference-source-attribution scenario 1', solve('preference-source-attribution', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'size':'workspace','theme':'session'})
check('preference-source-attribution scenario 2', solve('preference-source-attribution', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'default'})
check('preference-source-attribution scenario 3', solve('preference-source-attribution', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':'session'})
check('preference-source-attribution scenario 4', solve('preference-source-attribution', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':'device'})
check('preference-source-attribution scenario 5', solve('preference-source-attribution', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'session'})
check('preference-source-attribution scenario 6', solve('preference-source-attribution', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':'session'})
check('redundant-device-override-pruning scenario 1', solve('redundant-device-override-pruning', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 2', solve('redundant-device-override-pruning', ({'theme':'light'}, {},{}, {},[],[])), {})
check('redundant-device-override-pruning scenario 3', solve('redundant-device-override-pruning', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('redundant-device-override-pruning scenario 4', solve('redundant-device-override-pruning', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('redundant-device-override-pruning scenario 5', solve('redundant-device-override-pruning', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 6', solve('redundant-device-override-pruning', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('workspace-lock-report scenario 1', solve('workspace-lock-report', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['size'])
check('workspace-lock-report scenario 2', solve('workspace-lock-report', ({'theme':'light'}, {},{}, {},[],[])), [])
check('workspace-lock-report scenario 3', solve('workspace-lock-report', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('workspace-lock-report scenario 4', solve('workspace-lock-report', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('workspace-lock-report scenario 5', solve('workspace-lock-report', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), [])
check('workspace-lock-report scenario 6', solve('workspace-lock-report', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), [])
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(operation, s):
    defaults, device, workspace, session, locked, removed = s
    if operation == 'layer-precedence':
        return {**defaults,**device,**workspace,**session}
    if operation == 'locked-workspace-values':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in locked}}
    if operation == 'session-only-reset':
        return {**defaults,**device,**workspace}
    if operation == 'device-layer-serialization':
        return dict(device)
    if operation == 'explicit-session-keys':
        return list(session)
    if operation == 'session-key-removal-falls-through':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in removed}}
    if operation == 'writable-preference-projection':
        return {k:v for k,v in session.items() if k not in locked}
    if operation == 'preference-source-attribution':
        return {k:'device' for k in device}
    if operation == 'redundant-device-override-pruning':
        return {k:v for k,v in device.items() if k not in defaults or defaults[k]!=v}
    if operation == 'workspace-lock-report':
        return [k for k in locked if k in workspace]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layer-precedence scenario 1', solve('layer-precedence', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('layer-precedence scenario 2', solve('layer-precedence', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('layer-precedence scenario 3', solve('layer-precedence', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':4})
check('layer-precedence scenario 4', solve('layer-precedence', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('layer-precedence scenario 5', solve('layer-precedence', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('layer-precedence scenario 6', solve('layer-precedence', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('locked-workspace-values scenario 1', solve('locked-workspace-values', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('locked-workspace-values scenario 2', solve('locked-workspace-values', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('locked-workspace-values scenario 3', solve('locked-workspace-values', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('locked-workspace-values scenario 4', solve('locked-workspace-values', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('locked-workspace-values scenario 5', solve('locked-workspace-values', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('locked-workspace-values scenario 6', solve('locked-workspace-values', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('session-only-reset scenario 1', solve('session-only-reset', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark','size':N})
check('session-only-reset scenario 2', solve('session-only-reset', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-only-reset scenario 3', solve('session-only-reset', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-only-reset scenario 4', solve('session-only-reset', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-only-reset scenario 5', solve('session-only-reset', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-only-reset scenario 6', solve('session-only-reset', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':3})
check('device-layer-serialization scenario 1', solve('device-layer-serialization', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('device-layer-serialization scenario 2', solve('device-layer-serialization', ({'theme':'light'}, {},{}, {},[],[])), {})
check('device-layer-serialization scenario 3', solve('device-layer-serialization', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('device-layer-serialization scenario 4', solve('device-layer-serialization', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('device-layer-serialization scenario 5', solve('device-layer-serialization', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('device-layer-serialization scenario 6', solve('device-layer-serialization', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('explicit-session-keys scenario 1', solve('explicit-session-keys', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['theme'])
check('explicit-session-keys scenario 2', solve('explicit-session-keys', ({'theme':'light'}, {},{}, {},[],[])), [])
check('explicit-session-keys scenario 3', solve('explicit-session-keys', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('explicit-session-keys scenario 4', solve('explicit-session-keys', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('explicit-session-keys scenario 5', solve('explicit-session-keys', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), ['theme'])
check('explicit-session-keys scenario 6', solve('explicit-session-keys', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), ['size'])
check('session-key-removal-falls-through scenario 1', solve('session-key-removal-falls-through', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('session-key-removal-falls-through scenario 2', solve('session-key-removal-falls-through', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-key-removal-falls-through scenario 3', solve('session-key-removal-falls-through', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-key-removal-falls-through scenario 4', solve('session-key-removal-falls-through', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-key-removal-falls-through scenario 5', solve('session-key-removal-falls-through', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-key-removal-falls-through scenario 6', solve('session-key-removal-falls-through', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('writable-preference-projection scenario 1', solve('writable-preference-projection', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':''})
check('writable-preference-projection scenario 2', solve('writable-preference-projection', ({'theme':'light'}, {},{}, {},[],[])), {})
check('writable-preference-projection scenario 3', solve('writable-preference-projection', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {})
check('writable-preference-projection scenario 4', solve('writable-preference-projection', ({'theme':'light'},{'theme':None},{},{},[],[])), {})
check('writable-preference-projection scenario 5', solve('writable-preference-projection', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('writable-preference-projection scenario 6', solve('writable-preference-projection', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('preference-source-attribution scenario 1', solve('preference-source-attribution', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'size':'workspace','theme':'session'})
check('preference-source-attribution scenario 2', solve('preference-source-attribution', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'default'})
check('preference-source-attribution scenario 3', solve('preference-source-attribution', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':'session'})
check('preference-source-attribution scenario 4', solve('preference-source-attribution', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':'device'})
check('preference-source-attribution scenario 5', solve('preference-source-attribution', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'session'})
check('preference-source-attribution scenario 6', solve('preference-source-attribution', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':'session'})
check('redundant-device-override-pruning scenario 1', solve('redundant-device-override-pruning', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 2', solve('redundant-device-override-pruning', ({'theme':'light'}, {},{}, {},[],[])), {})
check('redundant-device-override-pruning scenario 3', solve('redundant-device-override-pruning', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('redundant-device-override-pruning scenario 4', solve('redundant-device-override-pruning', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('redundant-device-override-pruning scenario 5', solve('redundant-device-override-pruning', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 6', solve('redundant-device-override-pruning', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('workspace-lock-report scenario 1', solve('workspace-lock-report', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['size'])
check('workspace-lock-report scenario 2', solve('workspace-lock-report', ({'theme':'light'}, {},{}, {},[],[])), [])
check('workspace-lock-report scenario 3', solve('workspace-lock-report', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('workspace-lock-report scenario 4', solve('workspace-lock-report', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('workspace-lock-report scenario 5', solve('workspace-lock-report', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), [])
check('workspace-lock-report scenario 6', solve('workspace-lock-report', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), [])
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:
Preference source attribution.

Client preferences overlay defaults, device, workspace and session in that order. Workspace locks exclude session writes. Removing an override reveals the lower layer; serialization preserves its own layer and explicit null/falsy values. Operation preference-source-attribution has the six explicit input/output oracles below.

split: open-access


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

N = 1
observations = []
def solve(operation, s):
    defaults, device, workspace, session, locked, removed = s
    if operation == 'layer-precedence':
        return {**defaults,**device,**workspace,**session}
    if operation == 'locked-workspace-values':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in locked}}
    if operation == 'session-only-reset':
        return {**defaults,**device,**workspace}
    if operation == 'device-layer-serialization':
        return dict(device)
    if operation == 'explicit-session-keys':
        return list(session)
    if operation == 'session-key-removal-falls-through':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in removed}}
    if operation == 'writable-preference-projection':
        return {k:v for k,v in session.items() if k not in locked}
    if operation == 'preference-source-attribution':
        return {k:next(layer for layer,values in [('session',session),('workspace',workspace),('device',device),('default',defaults)] if k in values) for k in sorted(set(defaults)|set(device)|set(workspace)|set(session))}
    if operation == 'redundant-device-override-pruning':
        return {}
    if operation == 'workspace-lock-report':
        return [k for k in locked if k in workspace]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layer-precedence scenario 1', solve('layer-precedence', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('layer-precedence scenario 2', solve('layer-precedence', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('layer-precedence scenario 3', solve('layer-precedence', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':4})
check('layer-precedence scenario 4', solve('layer-precedence', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('layer-precedence scenario 5', solve('layer-precedence', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('layer-precedence scenario 6', solve('layer-precedence', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('locked-workspace-values scenario 1', solve('locked-workspace-values', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('locked-workspace-values scenario 2', solve('locked-workspace-values', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('locked-workspace-values scenario 3', solve('locked-workspace-values', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('locked-workspace-values scenario 4', solve('locked-workspace-values', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('locked-workspace-values scenario 5', solve('locked-workspace-values', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('locked-workspace-values scenario 6', solve('locked-workspace-values', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('session-only-reset scenario 1', solve('session-only-reset', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark','size':N})
check('session-only-reset scenario 2', solve('session-only-reset', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-only-reset scenario 3', solve('session-only-reset', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-only-reset scenario 4', solve('session-only-reset', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-only-reset scenario 5', solve('session-only-reset', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-only-reset scenario 6', solve('session-only-reset', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':3})
check('device-layer-serialization scenario 1', solve('device-layer-serialization', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('device-layer-serialization scenario 2', solve('device-layer-serialization', ({'theme':'light'}, {},{}, {},[],[])), {})
check('device-layer-serialization scenario 3', solve('device-layer-serialization', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('device-layer-serialization scenario 4', solve('device-layer-serialization', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('device-layer-serialization scenario 5', solve('device-layer-serialization', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('device-layer-serialization scenario 6', solve('device-layer-serialization', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('explicit-session-keys scenario 1', solve('explicit-session-keys', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['theme'])
check('explicit-session-keys scenario 2', solve('explicit-session-keys', ({'theme':'light'}, {},{}, {},[],[])), [])
check('explicit-session-keys scenario 3', solve('explicit-session-keys', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('explicit-session-keys scenario 4', solve('explicit-session-keys', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('explicit-session-keys scenario 5', solve('explicit-session-keys', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), ['theme'])
check('explicit-session-keys scenario 6', solve('explicit-session-keys', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), ['size'])
check('session-key-removal-falls-through scenario 1', solve('session-key-removal-falls-through', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('session-key-removal-falls-through scenario 2', solve('session-key-removal-falls-through', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-key-removal-falls-through scenario 3', solve('session-key-removal-falls-through', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-key-removal-falls-through scenario 4', solve('session-key-removal-falls-through', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-key-removal-falls-through scenario 5', solve('session-key-removal-falls-through', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-key-removal-falls-through scenario 6', solve('session-key-removal-falls-through', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('writable-preference-projection scenario 1', solve('writable-preference-projection', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':''})
check('writable-preference-projection scenario 2', solve('writable-preference-projection', ({'theme':'light'}, {},{}, {},[],[])), {})
check('writable-preference-projection scenario 3', solve('writable-preference-projection', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {})
check('writable-preference-projection scenario 4', solve('writable-preference-projection', ({'theme':'light'},{'theme':None},{},{},[],[])), {})
check('writable-preference-projection scenario 5', solve('writable-preference-projection', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('writable-preference-projection scenario 6', solve('writable-preference-projection', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('preference-source-attribution scenario 1', solve('preference-source-attribution', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'size':'workspace','theme':'session'})
check('preference-source-attribution scenario 2', solve('preference-source-attribution', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'default'})
check('preference-source-attribution scenario 3', solve('preference-source-attribution', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':'session'})
check('preference-source-attribution scenario 4', solve('preference-source-attribution', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':'device'})
check('preference-source-attribution scenario 5', solve('preference-source-attribution', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'session'})
check('preference-source-attribution scenario 6', solve('preference-source-attribution', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':'session'})
check('redundant-device-override-pruning scenario 1', solve('redundant-device-override-pruning', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 2', solve('redundant-device-override-pruning', ({'theme':'light'}, {},{}, {},[],[])), {})
check('redundant-device-override-pruning scenario 3', solve('redundant-device-override-pruning', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('redundant-device-override-pruning scenario 4', solve('redundant-device-override-pruning', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('redundant-device-override-pruning scenario 5', solve('redundant-device-override-pruning', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 6', solve('redundant-device-override-pruning', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('workspace-lock-report scenario 1', solve('workspace-lock-report', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['size'])
check('workspace-lock-report scenario 2', solve('workspace-lock-report', ({'theme':'light'}, {},{}, {},[],[])), [])
check('workspace-lock-report scenario 3', solve('workspace-lock-report', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('workspace-lock-report scenario 4', solve('workspace-lock-report', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('workspace-lock-report scenario 5', solve('workspace-lock-report', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), [])
check('workspace-lock-report scenario 6', solve('workspace-lock-report', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), [])
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(operation, s):
    defaults, device, workspace, session, locked, removed = s
    if operation == 'layer-precedence':
        return {**defaults,**device,**workspace,**session}
    if operation == 'locked-workspace-values':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in locked}}
    if operation == 'session-only-reset':
        return {**defaults,**device,**workspace}
    if operation == 'device-layer-serialization':
        return dict(device)
    if operation == 'explicit-session-keys':
        return list(session)
    if operation == 'session-key-removal-falls-through':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in removed}}
    if operation == 'writable-preference-projection':
        return {k:v for k,v in session.items() if k not in locked}
    if operation == 'preference-source-attribution':
        return {k:next(layer for layer,values in [('session',session),('workspace',workspace),('device',device),('default',defaults)] if k in values) for k in sorted(set(defaults)|set(device)|set(workspace)|set(session))}
    if operation == 'redundant-device-override-pruning':
        return {k:v for k,v in device.items() if k in defaults and defaults[k]!=v}
    if operation == 'workspace-lock-report':
        return [k for k in locked if k in workspace]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layer-precedence scenario 1', solve('layer-precedence', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('layer-precedence scenario 2', solve('layer-precedence', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('layer-precedence scenario 3', solve('layer-precedence', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':4})
check('layer-precedence scenario 4', solve('layer-precedence', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('layer-precedence scenario 5', solve('layer-precedence', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('layer-precedence scenario 6', solve('layer-precedence', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('locked-workspace-values scenario 1', solve('locked-workspace-values', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('locked-workspace-values scenario 2', solve('locked-workspace-values', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('locked-workspace-values scenario 3', solve('locked-workspace-values', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('locked-workspace-values scenario 4', solve('locked-workspace-values', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('locked-workspace-values scenario 5', solve('locked-workspace-values', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('locked-workspace-values scenario 6', solve('locked-workspace-values', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('session-only-reset scenario 1', solve('session-only-reset', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark','size':N})
check('session-only-reset scenario 2', solve('session-only-reset', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-only-reset scenario 3', solve('session-only-reset', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-only-reset scenario 4', solve('session-only-reset', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-only-reset scenario 5', solve('session-only-reset', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-only-reset scenario 6', solve('session-only-reset', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':3})
check('device-layer-serialization scenario 1', solve('device-layer-serialization', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('device-layer-serialization scenario 2', solve('device-layer-serialization', ({'theme':'light'}, {},{}, {},[],[])), {})
check('device-layer-serialization scenario 3', solve('device-layer-serialization', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('device-layer-serialization scenario 4', solve('device-layer-serialization', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('device-layer-serialization scenario 5', solve('device-layer-serialization', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('device-layer-serialization scenario 6', solve('device-layer-serialization', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('explicit-session-keys scenario 1', solve('explicit-session-keys', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['theme'])
check('explicit-session-keys scenario 2', solve('explicit-session-keys', ({'theme':'light'}, {},{}, {},[],[])), [])
check('explicit-session-keys scenario 3', solve('explicit-session-keys', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('explicit-session-keys scenario 4', solve('explicit-session-keys', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('explicit-session-keys scenario 5', solve('explicit-session-keys', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), ['theme'])
check('explicit-session-keys scenario 6', solve('explicit-session-keys', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), ['size'])
check('session-key-removal-falls-through scenario 1', solve('session-key-removal-falls-through', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('session-key-removal-falls-through scenario 2', solve('session-key-removal-falls-through', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-key-removal-falls-through scenario 3', solve('session-key-removal-falls-through', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-key-removal-falls-through scenario 4', solve('session-key-removal-falls-through', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-key-removal-falls-through scenario 5', solve('session-key-removal-falls-through', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-key-removal-falls-through scenario 6', solve('session-key-removal-falls-through', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('writable-preference-projection scenario 1', solve('writable-preference-projection', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':''})
check('writable-preference-projection scenario 2', solve('writable-preference-projection', ({'theme':'light'}, {},{}, {},[],[])), {})
check('writable-preference-projection scenario 3', solve('writable-preference-projection', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {})
check('writable-preference-projection scenario 4', solve('writable-preference-projection', ({'theme':'light'},{'theme':None},{},{},[],[])), {})
check('writable-preference-projection scenario 5', solve('writable-preference-projection', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('writable-preference-projection scenario 6', solve('writable-preference-projection', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('preference-source-attribution scenario 1', solve('preference-source-attribution', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'size':'workspace','theme':'session'})
check('preference-source-attribution scenario 2', solve('preference-source-attribution', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'default'})
check('preference-source-attribution scenario 3', solve('preference-source-attribution', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':'session'})
check('preference-source-attribution scenario 4', solve('preference-source-attribution', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':'device'})
check('preference-source-attribution scenario 5', solve('preference-source-attribution', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'session'})
check('preference-source-attribution scenario 6', solve('preference-source-attribution', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':'session'})
check('redundant-device-override-pruning scenario 1', solve('redundant-device-override-pruning', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 2', solve('redundant-device-override-pruning', ({'theme':'light'}, {},{}, {},[],[])), {})
check('redundant-device-override-pruning scenario 3', solve('redundant-device-override-pruning', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('redundant-device-override-pruning scenario 4', solve('redundant-device-override-pruning', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('redundant-device-override-pruning scenario 5', solve('redundant-device-override-pruning', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 6', solve('redundant-device-override-pruning', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('workspace-lock-report scenario 1', solve('workspace-lock-report', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['size'])
check('workspace-lock-report scenario 2', solve('workspace-lock-report', ({'theme':'light'}, {},{}, {},[],[])), [])
check('workspace-lock-report scenario 3', solve('workspace-lock-report', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('workspace-lock-report scenario 4', solve('workspace-lock-report', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('workspace-lock-report scenario 5', solve('workspace-lock-report', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), [])
check('workspace-lock-report scenario 6', solve('workspace-lock-report', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), [])
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:
Redundant device override pruning.

Client preferences overlay defaults, device, workspace and session in that order. Workspace locks exclude session writes. Removing an override reveals the lower layer; serialization preserves its own layer and explicit null/falsy values. Operation redundant-device-override-pruning has the six explicit input/output oracles below.

split: open-access


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

N = 1
observations = []
def solve(operation, s):
    defaults, device, workspace, session, locked, removed = s
    if operation == 'layer-precedence':
        return {**defaults,**device,**workspace,**session}
    if operation == 'locked-workspace-values':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in locked}}
    if operation == 'session-only-reset':
        return {**defaults,**device,**workspace}
    if operation == 'device-layer-serialization':
        return dict(device)
    if operation == 'explicit-session-keys':
        return list(session)
    if operation == 'session-key-removal-falls-through':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in removed}}
    if operation == 'writable-preference-projection':
        return {k:v for k,v in session.items() if k not in locked}
    if operation == 'preference-source-attribution':
        return {k:next(layer for layer,values in [('session',session),('workspace',workspace),('device',device),('default',defaults)] if k in values) for k in sorted(set(defaults)|set(device)|set(workspace)|set(session))}
    if operation == 'redundant-device-override-pruning':
        return {k:v for k,v in device.items() if k not in defaults or defaults[k]!=v}
    if operation == 'workspace-lock-report':
        return locked+list(session)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layer-precedence scenario 1', solve('layer-precedence', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('layer-precedence scenario 2', solve('layer-precedence', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('layer-precedence scenario 3', solve('layer-precedence', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':4})
check('layer-precedence scenario 4', solve('layer-precedence', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('layer-precedence scenario 5', solve('layer-precedence', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('layer-precedence scenario 6', solve('layer-precedence', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('locked-workspace-values scenario 1', solve('locked-workspace-values', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('locked-workspace-values scenario 2', solve('locked-workspace-values', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('locked-workspace-values scenario 3', solve('locked-workspace-values', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('locked-workspace-values scenario 4', solve('locked-workspace-values', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('locked-workspace-values scenario 5', solve('locked-workspace-values', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('locked-workspace-values scenario 6', solve('locked-workspace-values', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('session-only-reset scenario 1', solve('session-only-reset', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark','size':N})
check('session-only-reset scenario 2', solve('session-only-reset', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-only-reset scenario 3', solve('session-only-reset', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-only-reset scenario 4', solve('session-only-reset', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-only-reset scenario 5', solve('session-only-reset', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-only-reset scenario 6', solve('session-only-reset', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':3})
check('device-layer-serialization scenario 1', solve('device-layer-serialization', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('device-layer-serialization scenario 2', solve('device-layer-serialization', ({'theme':'light'}, {},{}, {},[],[])), {})
check('device-layer-serialization scenario 3', solve('device-layer-serialization', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('device-layer-serialization scenario 4', solve('device-layer-serialization', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('device-layer-serialization scenario 5', solve('device-layer-serialization', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('device-layer-serialization scenario 6', solve('device-layer-serialization', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('explicit-session-keys scenario 1', solve('explicit-session-keys', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['theme'])
check('explicit-session-keys scenario 2', solve('explicit-session-keys', ({'theme':'light'}, {},{}, {},[],[])), [])
check('explicit-session-keys scenario 3', solve('explicit-session-keys', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('explicit-session-keys scenario 4', solve('explicit-session-keys', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('explicit-session-keys scenario 5', solve('explicit-session-keys', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), ['theme'])
check('explicit-session-keys scenario 6', solve('explicit-session-keys', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), ['size'])
check('session-key-removal-falls-through scenario 1', solve('session-key-removal-falls-through', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('session-key-removal-falls-through scenario 2', solve('session-key-removal-falls-through', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-key-removal-falls-through scenario 3', solve('session-key-removal-falls-through', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-key-removal-falls-through scenario 4', solve('session-key-removal-falls-through', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-key-removal-falls-through scenario 5', solve('session-key-removal-falls-through', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-key-removal-falls-through scenario 6', solve('session-key-removal-falls-through', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('writable-preference-projection scenario 1', solve('writable-preference-projection', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':''})
check('writable-preference-projection scenario 2', solve('writable-preference-projection', ({'theme':'light'}, {},{}, {},[],[])), {})
check('writable-preference-projection scenario 3', solve('writable-preference-projection', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {})
check('writable-preference-projection scenario 4', solve('writable-preference-projection', ({'theme':'light'},{'theme':None},{},{},[],[])), {})
check('writable-preference-projection scenario 5', solve('writable-preference-projection', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('writable-preference-projection scenario 6', solve('writable-preference-projection', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('preference-source-attribution scenario 1', solve('preference-source-attribution', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'size':'workspace','theme':'session'})
check('preference-source-attribution scenario 2', solve('preference-source-attribution', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'default'})
check('preference-source-attribution scenario 3', solve('preference-source-attribution', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':'session'})
check('preference-source-attribution scenario 4', solve('preference-source-attribution', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':'device'})
check('preference-source-attribution scenario 5', solve('preference-source-attribution', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'session'})
check('preference-source-attribution scenario 6', solve('preference-source-attribution', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':'session'})
check('redundant-device-override-pruning scenario 1', solve('redundant-device-override-pruning', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 2', solve('redundant-device-override-pruning', ({'theme':'light'}, {},{}, {},[],[])), {})
check('redundant-device-override-pruning scenario 3', solve('redundant-device-override-pruning', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('redundant-device-override-pruning scenario 4', solve('redundant-device-override-pruning', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('redundant-device-override-pruning scenario 5', solve('redundant-device-override-pruning', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 6', solve('redundant-device-override-pruning', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('workspace-lock-report scenario 1', solve('workspace-lock-report', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['size'])
check('workspace-lock-report scenario 2', solve('workspace-lock-report', ({'theme':'light'}, {},{}, {},[],[])), [])
check('workspace-lock-report scenario 3', solve('workspace-lock-report', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('workspace-lock-report scenario 4', solve('workspace-lock-report', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('workspace-lock-report scenario 5', solve('workspace-lock-report', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), [])
check('workspace-lock-report scenario 6', solve('workspace-lock-report', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), [])
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(operation, s):
    defaults, device, workspace, session, locked, removed = s
    if operation == 'layer-precedence':
        return {**defaults,**device,**workspace,**session}
    if operation == 'locked-workspace-values':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in locked}}
    if operation == 'session-only-reset':
        return {**defaults,**device,**workspace}
    if operation == 'device-layer-serialization':
        return dict(device)
    if operation == 'explicit-session-keys':
        return list(session)
    if operation == 'session-key-removal-falls-through':
        return {**defaults,**device,**workspace,**{k:v for k,v in session.items() if k not in removed}}
    if operation == 'writable-preference-projection':
        return {k:v for k,v in session.items() if k not in locked}
    if operation == 'preference-source-attribution':
        return {k:next(layer for layer,values in [('session',session),('workspace',workspace),('device',device),('default',defaults)] if k in values) for k in sorted(set(defaults)|set(device)|set(workspace)|set(session))}
    if operation == 'redundant-device-override-pruning':
        return {k:v for k,v in device.items() if k not in defaults or defaults[k]!=v}
    if operation == 'workspace-lock-report':
        return [k for k in locked if k in session]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('layer-precedence scenario 1', solve('layer-precedence', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('layer-precedence scenario 2', solve('layer-precedence', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('layer-precedence scenario 3', solve('layer-precedence', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':4})
check('layer-precedence scenario 4', solve('layer-precedence', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('layer-precedence scenario 5', solve('layer-precedence', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('layer-precedence scenario 6', solve('layer-precedence', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('locked-workspace-values scenario 1', solve('locked-workspace-values', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('locked-workspace-values scenario 2', solve('locked-workspace-values', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('locked-workspace-values scenario 3', solve('locked-workspace-values', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('locked-workspace-values scenario 4', solve('locked-workspace-values', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('locked-workspace-values scenario 5', solve('locked-workspace-values', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('locked-workspace-values scenario 6', solve('locked-workspace-values', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('session-only-reset scenario 1', solve('session-only-reset', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark','size':N})
check('session-only-reset scenario 2', solve('session-only-reset', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-only-reset scenario 3', solve('session-only-reset', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-only-reset scenario 4', solve('session-only-reset', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-only-reset scenario 5', solve('session-only-reset', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-only-reset scenario 6', solve('session-only-reset', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':3})
check('device-layer-serialization scenario 1', solve('device-layer-serialization', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('device-layer-serialization scenario 2', solve('device-layer-serialization', ({'theme':'light'}, {},{}, {},[],[])), {})
check('device-layer-serialization scenario 3', solve('device-layer-serialization', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('device-layer-serialization scenario 4', solve('device-layer-serialization', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('device-layer-serialization scenario 5', solve('device-layer-serialization', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('device-layer-serialization scenario 6', solve('device-layer-serialization', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('explicit-session-keys scenario 1', solve('explicit-session-keys', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['theme'])
check('explicit-session-keys scenario 2', solve('explicit-session-keys', ({'theme':'light'}, {},{}, {},[],[])), [])
check('explicit-session-keys scenario 3', solve('explicit-session-keys', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('explicit-session-keys scenario 4', solve('explicit-session-keys', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('explicit-session-keys scenario 5', solve('explicit-session-keys', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), ['theme'])
check('explicit-session-keys scenario 6', solve('explicit-session-keys', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), ['size'])
check('session-key-removal-falls-through scenario 1', solve('session-key-removal-falls-through', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'','size':N})
check('session-key-removal-falls-through scenario 2', solve('session-key-removal-falls-through', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'light'})
check('session-key-removal-falls-through scenario 3', solve('session-key-removal-falls-through', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':3})
check('session-key-removal-falls-through scenario 4', solve('session-key-removal-falls-through', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('session-key-removal-falls-through scenario 5', solve('session-key-removal-falls-through', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'light'})
check('session-key-removal-falls-through scenario 6', solve('session-key-removal-falls-through', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('writable-preference-projection scenario 1', solve('writable-preference-projection', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':''})
check('writable-preference-projection scenario 2', solve('writable-preference-projection', ({'theme':'light'}, {},{}, {},[],[])), {})
check('writable-preference-projection scenario 3', solve('writable-preference-projection', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {})
check('writable-preference-projection scenario 4', solve('writable-preference-projection', ({'theme':'light'},{'theme':None},{},{},[],[])), {})
check('writable-preference-projection scenario 5', solve('writable-preference-projection', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'blue'})
check('writable-preference-projection scenario 6', solve('writable-preference-projection', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':0})
check('preference-source-attribution scenario 1', solve('preference-source-attribution', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'size':'workspace','theme':'session'})
check('preference-source-attribution scenario 2', solve('preference-source-attribution', ({'theme':'light'}, {},{}, {},[],[])), {'theme':'default'})
check('preference-source-attribution scenario 3', solve('preference-source-attribution', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':'session'})
check('preference-source-attribution scenario 4', solve('preference-source-attribution', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':'device'})
check('preference-source-attribution scenario 5', solve('preference-source-attribution', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'session'})
check('preference-source-attribution scenario 6', solve('preference-source-attribution', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':'session'})
check('redundant-device-override-pruning scenario 1', solve('redundant-device-override-pruning', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 2', solve('redundant-device-override-pruning', ({'theme':'light'}, {},{}, {},[],[])), {})
check('redundant-device-override-pruning scenario 3', solve('redundant-device-override-pruning', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), {'size':0})
check('redundant-device-override-pruning scenario 4', solve('redundant-device-override-pruning', ({'theme':'light'},{'theme':None},{},{},[],[])), {'theme':None})
check('redundant-device-override-pruning scenario 5', solve('redundant-device-override-pruning', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), {'theme':'dark'})
check('redundant-device-override-pruning scenario 6', solve('redundant-device-override-pruning', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), {'size':2})
check('workspace-lock-report scenario 1', solve('workspace-lock-report', ({'theme':'light','size':1},{'theme':'dark'},{'size':N},{'theme':''},['size'],[])), ['size'])
check('workspace-lock-report scenario 2', solve('workspace-lock-report', ({'theme':'light'}, {},{}, {},[],[])), [])
check('workspace-lock-report scenario 3', solve('workspace-lock-report', ({'size':2},{'size':0},{'size':3},{'size':4},['size'],['size'])), ['size'])
check('workspace-lock-report scenario 4', solve('workspace-lock-report', ({'theme':'light'},{'theme':None},{},{},[],[])), [])
check('workspace-lock-report scenario 5', solve('workspace-lock-report', ({}, {'theme':'dark'},{'theme':'light'},{'theme':'blue'},[],['theme'])), [])
check('workspace-lock-report scenario 6', solve('workspace-lock-report', ({'size':1}, {'size':2},{'size':3},{'size':0},[],[])), [])
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:
Workspace lock report.

Client preferences overlay defaults, device, workspace and session in that order. Workspace locks exclude session writes. Removing an override reveals the lower layer; serialization preserves its own layer and explicit null/falsy values. Operation workspace-lock-report has the six explicit input/output oracles below.

split: open-access


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

N = 1
observations = []
def solve(segments, failed_segment, error):
    return {k:{'error':error,'data':None} for k in segments}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nested child', solve({'layout':{'data':N},'child':{'data':2}},'child','bad'), {'layout':{'data':N},'child':{'error':'bad','data':None}})
check('layout failure', solve({'layout':{'data':N},'child':{'data':2}},'layout','bad'), {'layout':{'error':'bad','data':None},'child':{'data':2}})
check('unknown segment', solve({'layout':{'data':N}},'gone','bad'), {'layout':{'data':N}})
check('empty tree', solve({},'child','bad'), {})
check('null failure payload', solve({'child':{'data':N}},'child',None), {'child':{'error':None,'data':None}})
check('empty error text', solve({'child':{'data':N},'side':{}},'child',''), {'child':{'error':'','data':None},'side':{}})
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(segments, failed_segment, error):
    return {k:v for k,v in segments.items() if k!=failed_segment}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('nested child', solve({'layout':{'data':N},'child':{'data':2}},'child','bad'), {'layout':{'data':N},'child':{'error':'bad','data':None}})
check('layout failure', solve({'layout':{'data':N},'child':{'data':2}},'layout','bad'), {'layout':{'error':'bad','data':None},'child':{'data':2}})
check('unknown segment', solve({'layout':{'data':N}},'gone','bad'), {'layout':{'data':N}})
check('empty tree', solve({},'child','bad'), {})
check('null failure payload', solve({'child':{'data':N}},'child',None), {'child':{'error':None,'data':None}})
check('empty error text', solve({'child':{'data':N},'side':{}},'child',''), {'child':{'error':'','data':None},'side':{}})
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 nested route failure clears unrelated loaded segments.

An error replaces only the matching route segment state with an error/data pair; siblings and unknown segment IDs are unchanged.

split: open-access


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

N = 1
observations = []
def solve(pending, links, committed):
    return [x for x in pending if x not in committed]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('chain closure', solve(list(range(N+3)),[(i,i+1) for i in range(N+1)],[0]), [N+2])
check('reverse dependency', solve(['a','b','c'],[('a','b')],['b']), ['c'])
check('cycle', solve(['a','b','c'],[('a','b'),('b','a')],['a']), ['c'])
check('unrelated lane', solve(['a','b'],[],['a']), ['b'])
check('no commit', solve(['a','b'],[('a','b')],[]), ['a','b'])
check('already absent', solve(['c'],[('a','b')],['a']), ['c'])
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(pending, links, committed):
    done=set(committed)|{b for a,b in links if a in committed}
    return [x for x in pending if x not in done]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('chain closure', solve(list(range(N+3)),[(i,i+1) for i in range(N+1)],[0]), [N+2])
check('reverse dependency', solve(['a','b','c'],[('a','b')],['b']), ['c'])
check('cycle', solve(['a','b','c'],[('a','b'),('b','a')],['a']), ['c'])
check('unrelated lane', solve(['a','b'],[],['a']), ['b'])
check('no commit', solve(['a','b'],[('a','b')],[]), ['a','b'])
check('already absent', solve(['c'],[('a','b')],['a']), ['c'])
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 committed transition leaves its dependent render lanes pending.

Committing any render lane commits the undirected transitive closure of its entangled lanes; unrelated pending lanes retain order.

split: open-access


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

N = 1
observations = []
def solve(history, event, payload, capacity):
    return (history+[payload])[-capacity:] if event=='failure' else history
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('success clears', solve(['old'],'success',None,N), [])
check('failure bound', solve(list(range(N+1)),'failure',99,N), (list(range(N+1))+[99])[-N:])
check('zero history budget', solve(['old'],'failure','new',0), [])
check('start does not add error', solve(['old'],'start',None,2), ['old'])
check('empty text retained', solve([],'failure','',2), [''])
check('idle truncates existing', solve(['a','b'],'idle',None,1), ['b'])
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(history, event, payload, capacity):
    return [] if event=='success' else (history+[payload])[-capacity:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('success clears', solve(['old'],'success',None,N), [])
check('failure bound', solve(list(range(N+1)),'failure',99,N), (list(range(N+1))+[99])[-N:])
check('zero history budget', solve(['old'],'failure','new',0), [])
check('start does not add error', solve(['old'],'start',None,2), ['old'])
check('empty text retained', solve([],'failure','',2), [''])
check('idle truncates existing', solve(['a','b'],'idle',None,1), ['b'])
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 successful background refresh leaves the preceding error attempt visible.

Failure appends an error to a bounded history, success clears it, other events retain it, and capacity zero retains no errors.

split: open-access