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

N = 1
observations = []
def solve(operation, s):
    old, new, drafts, resources, pending, location, allowed = s
    if operation == 'workspace-draft-selection':
        return drafts.get(old)
    if operation == 'outgoing-resource-detach':
        return [(w,k) for w,k in resources if w!=old]
    if operation == 'outgoing-request-cancel':
        return [k for w,k in pending if w==old]
    if operation == 'switch-authorization':
        return new in allowed
    if operation == 'draft-preservation-on-switch':
        return dict(drafts)
    if operation == 'workspace-route-rewrite':
        return '/'+new+location[len('/'+old):] if location=='/'+old or location.startswith('/'+old+'/') else location
    if operation == 'same-workspace-no-switch':
        return old!=new
    if operation == 'resource-scope-key':
        return [(new,k) for w,k in resources if w==new]
    if operation == 'forbidden-switch-retains-owner':
        return new if new in allowed else old
    if operation == 'pending-other-workspaces':
        return [(w,k) for w,k in pending if w!=old]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('workspace-draft-selection scenario 1', solve('workspace-draft-selection', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 2)
check('workspace-draft-selection scenario 2', solve('workspace-draft-selection', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 0)
check('workspace-draft-selection scenario 3', solve('workspace-draft-selection', ('a','c',{},[],[('a','p')],'/a/doc',[])), None)
check('workspace-draft-selection scenario 4', solve('workspace-draft-selection', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), None)
check('workspace-draft-selection scenario 5', solve('workspace-draft-selection', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), False)
check('workspace-draft-selection scenario 6', solve('workspace-draft-selection', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), None)
check('outgoing-resource-detach scenario 1', solve('outgoing-resource-detach', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('outgoing-resource-detach scenario 2', solve('outgoing-resource-detach', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-resource-detach scenario 3', solve('outgoing-resource-detach', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('outgoing-resource-detach scenario 4', solve('outgoing-resource-detach', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-resource-detach scenario 5', solve('outgoing-resource-detach', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','x')])
check('outgoing-resource-detach scenario 6', solve('outgoing-resource-detach', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('outgoing-request-cancel scenario 1', solve('outgoing-request-cancel', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), ['p'])
check('outgoing-request-cancel scenario 2', solve('outgoing-request-cancel', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-request-cancel scenario 3', solve('outgoing-request-cancel', ('a','c',{},[],[('a','p')],'/a/doc',[])), ['p'])
check('outgoing-request-cancel scenario 4', solve('outgoing-request-cancel', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-request-cancel scenario 5', solve('outgoing-request-cancel', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('outgoing-request-cancel scenario 6', solve('outgoing-request-cancel', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), ['p','q'])
check('switch-authorization scenario 1', solve('switch-authorization', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('switch-authorization scenario 2', solve('switch-authorization', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), True)
check('switch-authorization scenario 3', solve('switch-authorization', ('a','c',{},[],[('a','p')],'/a/doc',[])), False)
check('switch-authorization scenario 4', solve('switch-authorization', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('switch-authorization scenario 5', solve('switch-authorization', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('switch-authorization scenario 6', solve('switch-authorization', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('draft-preservation-on-switch scenario 1', solve('draft-preservation-on-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), {'a':N,'b':2})
check('draft-preservation-on-switch scenario 2', solve('draft-preservation-on-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), {'a':0})
check('draft-preservation-on-switch scenario 3', solve('draft-preservation-on-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), {})
check('draft-preservation-on-switch scenario 4', solve('draft-preservation-on-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), {'b':None})
check('draft-preservation-on-switch scenario 5', solve('draft-preservation-on-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), {'b':False})
check('draft-preservation-on-switch scenario 6', solve('draft-preservation-on-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), {'a':N})
check('workspace-route-rewrite scenario 1', solve('workspace-route-rewrite', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), '/b/doc')
check('workspace-route-rewrite scenario 2', solve('workspace-route-rewrite', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), '/a')
check('workspace-route-rewrite scenario 3', solve('workspace-route-rewrite', ('a','c',{},[],[('a','p')],'/a/doc',[])), '/c/doc')
check('workspace-route-rewrite scenario 4', solve('workspace-route-rewrite', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), '/a')
check('workspace-route-rewrite scenario 5', solve('workspace-route-rewrite', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), '/shared')
check('workspace-route-rewrite scenario 6', solve('workspace-route-rewrite', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), '/b')
check('same-workspace-no-switch scenario 1', solve('same-workspace-no-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('same-workspace-no-switch scenario 2', solve('same-workspace-no-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), False)
check('same-workspace-no-switch scenario 3', solve('same-workspace-no-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), True)
check('same-workspace-no-switch scenario 4', solve('same-workspace-no-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('same-workspace-no-switch scenario 5', solve('same-workspace-no-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('same-workspace-no-switch scenario 6', solve('same-workspace-no-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('resource-scope-key scenario 1', solve('resource-scope-key', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('resource-scope-key scenario 2', solve('resource-scope-key', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [('a','x')])
check('resource-scope-key scenario 3', solve('resource-scope-key', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('resource-scope-key scenario 4', solve('resource-scope-key', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('resource-scope-key scenario 5', solve('resource-scope-key', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('resource-scope-key scenario 6', solve('resource-scope-key', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('forbidden-switch-retains-owner scenario 1', solve('forbidden-switch-retains-owner', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 2', solve('forbidden-switch-retains-owner', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 'a')
check('forbidden-switch-retains-owner scenario 3', solve('forbidden-switch-retains-owner', ('a','c',{},[],[('a','p')],'/a/doc',[])), 'a')
check('forbidden-switch-retains-owner scenario 4', solve('forbidden-switch-retains-owner', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), 'a')
check('forbidden-switch-retains-owner scenario 5', solve('forbidden-switch-retains-owner', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 6', solve('forbidden-switch-retains-owner', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), 'b')
check('pending-other-workspaces scenario 1', solve('pending-other-workspaces', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','q')])
check('pending-other-workspaces scenario 2', solve('pending-other-workspaces', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('pending-other-workspaces scenario 3', solve('pending-other-workspaces', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('pending-other-workspaces scenario 4', solve('pending-other-workspaces', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('pending-other-workspaces scenario 5', solve('pending-other-workspaces', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','p')])
check('pending-other-workspaces scenario 6', solve('pending-other-workspaces', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['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(operation, s):
    old, new, drafts, resources, pending, location, allowed = s
    if operation == 'workspace-draft-selection':
        return drafts.get(new) or drafts.get(old)
    if operation == 'outgoing-resource-detach':
        return [(w,k) for w,k in resources if w!=old]
    if operation == 'outgoing-request-cancel':
        return [k for w,k in pending if w==old]
    if operation == 'switch-authorization':
        return new in allowed
    if operation == 'draft-preservation-on-switch':
        return dict(drafts)
    if operation == 'workspace-route-rewrite':
        return '/'+new+location[len('/'+old):] if location=='/'+old or location.startswith('/'+old+'/') else location
    if operation == 'same-workspace-no-switch':
        return old!=new
    if operation == 'resource-scope-key':
        return [(new,k) for w,k in resources if w==new]
    if operation == 'forbidden-switch-retains-owner':
        return new if new in allowed else old
    if operation == 'pending-other-workspaces':
        return [(w,k) for w,k in pending if w!=old]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('workspace-draft-selection scenario 1', solve('workspace-draft-selection', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 2)
check('workspace-draft-selection scenario 2', solve('workspace-draft-selection', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 0)
check('workspace-draft-selection scenario 3', solve('workspace-draft-selection', ('a','c',{},[],[('a','p')],'/a/doc',[])), None)
check('workspace-draft-selection scenario 4', solve('workspace-draft-selection', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), None)
check('workspace-draft-selection scenario 5', solve('workspace-draft-selection', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), False)
check('workspace-draft-selection scenario 6', solve('workspace-draft-selection', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), None)
check('outgoing-resource-detach scenario 1', solve('outgoing-resource-detach', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('outgoing-resource-detach scenario 2', solve('outgoing-resource-detach', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-resource-detach scenario 3', solve('outgoing-resource-detach', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('outgoing-resource-detach scenario 4', solve('outgoing-resource-detach', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-resource-detach scenario 5', solve('outgoing-resource-detach', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','x')])
check('outgoing-resource-detach scenario 6', solve('outgoing-resource-detach', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('outgoing-request-cancel scenario 1', solve('outgoing-request-cancel', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), ['p'])
check('outgoing-request-cancel scenario 2', solve('outgoing-request-cancel', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-request-cancel scenario 3', solve('outgoing-request-cancel', ('a','c',{},[],[('a','p')],'/a/doc',[])), ['p'])
check('outgoing-request-cancel scenario 4', solve('outgoing-request-cancel', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-request-cancel scenario 5', solve('outgoing-request-cancel', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('outgoing-request-cancel scenario 6', solve('outgoing-request-cancel', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), ['p','q'])
check('switch-authorization scenario 1', solve('switch-authorization', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('switch-authorization scenario 2', solve('switch-authorization', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), True)
check('switch-authorization scenario 3', solve('switch-authorization', ('a','c',{},[],[('a','p')],'/a/doc',[])), False)
check('switch-authorization scenario 4', solve('switch-authorization', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('switch-authorization scenario 5', solve('switch-authorization', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('switch-authorization scenario 6', solve('switch-authorization', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('draft-preservation-on-switch scenario 1', solve('draft-preservation-on-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), {'a':N,'b':2})
check('draft-preservation-on-switch scenario 2', solve('draft-preservation-on-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), {'a':0})
check('draft-preservation-on-switch scenario 3', solve('draft-preservation-on-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), {})
check('draft-preservation-on-switch scenario 4', solve('draft-preservation-on-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), {'b':None})
check('draft-preservation-on-switch scenario 5', solve('draft-preservation-on-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), {'b':False})
check('draft-preservation-on-switch scenario 6', solve('draft-preservation-on-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), {'a':N})
check('workspace-route-rewrite scenario 1', solve('workspace-route-rewrite', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), '/b/doc')
check('workspace-route-rewrite scenario 2', solve('workspace-route-rewrite', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), '/a')
check('workspace-route-rewrite scenario 3', solve('workspace-route-rewrite', ('a','c',{},[],[('a','p')],'/a/doc',[])), '/c/doc')
check('workspace-route-rewrite scenario 4', solve('workspace-route-rewrite', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), '/a')
check('workspace-route-rewrite scenario 5', solve('workspace-route-rewrite', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), '/shared')
check('workspace-route-rewrite scenario 6', solve('workspace-route-rewrite', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), '/b')
check('same-workspace-no-switch scenario 1', solve('same-workspace-no-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('same-workspace-no-switch scenario 2', solve('same-workspace-no-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), False)
check('same-workspace-no-switch scenario 3', solve('same-workspace-no-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), True)
check('same-workspace-no-switch scenario 4', solve('same-workspace-no-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('same-workspace-no-switch scenario 5', solve('same-workspace-no-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('same-workspace-no-switch scenario 6', solve('same-workspace-no-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('resource-scope-key scenario 1', solve('resource-scope-key', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('resource-scope-key scenario 2', solve('resource-scope-key', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [('a','x')])
check('resource-scope-key scenario 3', solve('resource-scope-key', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('resource-scope-key scenario 4', solve('resource-scope-key', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('resource-scope-key scenario 5', solve('resource-scope-key', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('resource-scope-key scenario 6', solve('resource-scope-key', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('forbidden-switch-retains-owner scenario 1', solve('forbidden-switch-retains-owner', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 2', solve('forbidden-switch-retains-owner', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 'a')
check('forbidden-switch-retains-owner scenario 3', solve('forbidden-switch-retains-owner', ('a','c',{},[],[('a','p')],'/a/doc',[])), 'a')
check('forbidden-switch-retains-owner scenario 4', solve('forbidden-switch-retains-owner', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), 'a')
check('forbidden-switch-retains-owner scenario 5', solve('forbidden-switch-retains-owner', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 6', solve('forbidden-switch-retains-owner', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), 'b')
check('pending-other-workspaces scenario 1', solve('pending-other-workspaces', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','q')])
check('pending-other-workspaces scenario 2', solve('pending-other-workspaces', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('pending-other-workspaces scenario 3', solve('pending-other-workspaces', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('pending-other-workspaces scenario 4', solve('pending-other-workspaces', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('pending-other-workspaces scenario 5', solve('pending-other-workspaces', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','p')])
check('pending-other-workspaces scenario 6', solve('pending-other-workspaces', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['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:
Workspace draft selection.

Workspace switches preserve each workspace draft, detach only outgoing subscriptions and requests, retain unrelated workspace work, rewrite only the old route prefix, and keep the old workspace if access is not allowed. Operation workspace-draft-selection 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):
    old, new, drafts, resources, pending, location, allowed = s
    if operation == 'workspace-draft-selection':
        return drafts.get(new)
    if operation == 'outgoing-resource-detach':
        return []
    if operation == 'outgoing-request-cancel':
        return [k for w,k in pending if w==old]
    if operation == 'switch-authorization':
        return new in allowed
    if operation == 'draft-preservation-on-switch':
        return dict(drafts)
    if operation == 'workspace-route-rewrite':
        return '/'+new+location[len('/'+old):] if location=='/'+old or location.startswith('/'+old+'/') else location
    if operation == 'same-workspace-no-switch':
        return old!=new
    if operation == 'resource-scope-key':
        return [(new,k) for w,k in resources if w==new]
    if operation == 'forbidden-switch-retains-owner':
        return new if new in allowed else old
    if operation == 'pending-other-workspaces':
        return [(w,k) for w,k in pending if w!=old]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('workspace-draft-selection scenario 1', solve('workspace-draft-selection', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 2)
check('workspace-draft-selection scenario 2', solve('workspace-draft-selection', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 0)
check('workspace-draft-selection scenario 3', solve('workspace-draft-selection', ('a','c',{},[],[('a','p')],'/a/doc',[])), None)
check('workspace-draft-selection scenario 4', solve('workspace-draft-selection', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), None)
check('workspace-draft-selection scenario 5', solve('workspace-draft-selection', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), False)
check('workspace-draft-selection scenario 6', solve('workspace-draft-selection', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), None)
check('outgoing-resource-detach scenario 1', solve('outgoing-resource-detach', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('outgoing-resource-detach scenario 2', solve('outgoing-resource-detach', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-resource-detach scenario 3', solve('outgoing-resource-detach', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('outgoing-resource-detach scenario 4', solve('outgoing-resource-detach', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-resource-detach scenario 5', solve('outgoing-resource-detach', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','x')])
check('outgoing-resource-detach scenario 6', solve('outgoing-resource-detach', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('outgoing-request-cancel scenario 1', solve('outgoing-request-cancel', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), ['p'])
check('outgoing-request-cancel scenario 2', solve('outgoing-request-cancel', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-request-cancel scenario 3', solve('outgoing-request-cancel', ('a','c',{},[],[('a','p')],'/a/doc',[])), ['p'])
check('outgoing-request-cancel scenario 4', solve('outgoing-request-cancel', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-request-cancel scenario 5', solve('outgoing-request-cancel', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('outgoing-request-cancel scenario 6', solve('outgoing-request-cancel', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), ['p','q'])
check('switch-authorization scenario 1', solve('switch-authorization', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('switch-authorization scenario 2', solve('switch-authorization', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), True)
check('switch-authorization scenario 3', solve('switch-authorization', ('a','c',{},[],[('a','p')],'/a/doc',[])), False)
check('switch-authorization scenario 4', solve('switch-authorization', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('switch-authorization scenario 5', solve('switch-authorization', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('switch-authorization scenario 6', solve('switch-authorization', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('draft-preservation-on-switch scenario 1', solve('draft-preservation-on-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), {'a':N,'b':2})
check('draft-preservation-on-switch scenario 2', solve('draft-preservation-on-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), {'a':0})
check('draft-preservation-on-switch scenario 3', solve('draft-preservation-on-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), {})
check('draft-preservation-on-switch scenario 4', solve('draft-preservation-on-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), {'b':None})
check('draft-preservation-on-switch scenario 5', solve('draft-preservation-on-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), {'b':False})
check('draft-preservation-on-switch scenario 6', solve('draft-preservation-on-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), {'a':N})
check('workspace-route-rewrite scenario 1', solve('workspace-route-rewrite', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), '/b/doc')
check('workspace-route-rewrite scenario 2', solve('workspace-route-rewrite', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), '/a')
check('workspace-route-rewrite scenario 3', solve('workspace-route-rewrite', ('a','c',{},[],[('a','p')],'/a/doc',[])), '/c/doc')
check('workspace-route-rewrite scenario 4', solve('workspace-route-rewrite', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), '/a')
check('workspace-route-rewrite scenario 5', solve('workspace-route-rewrite', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), '/shared')
check('workspace-route-rewrite scenario 6', solve('workspace-route-rewrite', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), '/b')
check('same-workspace-no-switch scenario 1', solve('same-workspace-no-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('same-workspace-no-switch scenario 2', solve('same-workspace-no-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), False)
check('same-workspace-no-switch scenario 3', solve('same-workspace-no-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), True)
check('same-workspace-no-switch scenario 4', solve('same-workspace-no-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('same-workspace-no-switch scenario 5', solve('same-workspace-no-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('same-workspace-no-switch scenario 6', solve('same-workspace-no-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('resource-scope-key scenario 1', solve('resource-scope-key', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('resource-scope-key scenario 2', solve('resource-scope-key', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [('a','x')])
check('resource-scope-key scenario 3', solve('resource-scope-key', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('resource-scope-key scenario 4', solve('resource-scope-key', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('resource-scope-key scenario 5', solve('resource-scope-key', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('resource-scope-key scenario 6', solve('resource-scope-key', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('forbidden-switch-retains-owner scenario 1', solve('forbidden-switch-retains-owner', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 2', solve('forbidden-switch-retains-owner', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 'a')
check('forbidden-switch-retains-owner scenario 3', solve('forbidden-switch-retains-owner', ('a','c',{},[],[('a','p')],'/a/doc',[])), 'a')
check('forbidden-switch-retains-owner scenario 4', solve('forbidden-switch-retains-owner', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), 'a')
check('forbidden-switch-retains-owner scenario 5', solve('forbidden-switch-retains-owner', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 6', solve('forbidden-switch-retains-owner', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), 'b')
check('pending-other-workspaces scenario 1', solve('pending-other-workspaces', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','q')])
check('pending-other-workspaces scenario 2', solve('pending-other-workspaces', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('pending-other-workspaces scenario 3', solve('pending-other-workspaces', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('pending-other-workspaces scenario 4', solve('pending-other-workspaces', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('pending-other-workspaces scenario 5', solve('pending-other-workspaces', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','p')])
check('pending-other-workspaces scenario 6', solve('pending-other-workspaces', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['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)

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):
    old, new, drafts, resources, pending, location, allowed = s
    if operation == 'workspace-draft-selection':
        return drafts.get(new)
    if operation == 'outgoing-resource-detach':
        return [(w,k) for w,k in resources if w==new]
    if operation == 'outgoing-request-cancel':
        return [k for w,k in pending if w==old]
    if operation == 'switch-authorization':
        return new in allowed
    if operation == 'draft-preservation-on-switch':
        return dict(drafts)
    if operation == 'workspace-route-rewrite':
        return '/'+new+location[len('/'+old):] if location=='/'+old or location.startswith('/'+old+'/') else location
    if operation == 'same-workspace-no-switch':
        return old!=new
    if operation == 'resource-scope-key':
        return [(new,k) for w,k in resources if w==new]
    if operation == 'forbidden-switch-retains-owner':
        return new if new in allowed else old
    if operation == 'pending-other-workspaces':
        return [(w,k) for w,k in pending if w!=old]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('workspace-draft-selection scenario 1', solve('workspace-draft-selection', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 2)
check('workspace-draft-selection scenario 2', solve('workspace-draft-selection', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 0)
check('workspace-draft-selection scenario 3', solve('workspace-draft-selection', ('a','c',{},[],[('a','p')],'/a/doc',[])), None)
check('workspace-draft-selection scenario 4', solve('workspace-draft-selection', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), None)
check('workspace-draft-selection scenario 5', solve('workspace-draft-selection', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), False)
check('workspace-draft-selection scenario 6', solve('workspace-draft-selection', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), None)
check('outgoing-resource-detach scenario 1', solve('outgoing-resource-detach', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('outgoing-resource-detach scenario 2', solve('outgoing-resource-detach', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-resource-detach scenario 3', solve('outgoing-resource-detach', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('outgoing-resource-detach scenario 4', solve('outgoing-resource-detach', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-resource-detach scenario 5', solve('outgoing-resource-detach', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','x')])
check('outgoing-resource-detach scenario 6', solve('outgoing-resource-detach', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('outgoing-request-cancel scenario 1', solve('outgoing-request-cancel', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), ['p'])
check('outgoing-request-cancel scenario 2', solve('outgoing-request-cancel', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-request-cancel scenario 3', solve('outgoing-request-cancel', ('a','c',{},[],[('a','p')],'/a/doc',[])), ['p'])
check('outgoing-request-cancel scenario 4', solve('outgoing-request-cancel', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-request-cancel scenario 5', solve('outgoing-request-cancel', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('outgoing-request-cancel scenario 6', solve('outgoing-request-cancel', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), ['p','q'])
check('switch-authorization scenario 1', solve('switch-authorization', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('switch-authorization scenario 2', solve('switch-authorization', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), True)
check('switch-authorization scenario 3', solve('switch-authorization', ('a','c',{},[],[('a','p')],'/a/doc',[])), False)
check('switch-authorization scenario 4', solve('switch-authorization', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('switch-authorization scenario 5', solve('switch-authorization', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('switch-authorization scenario 6', solve('switch-authorization', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('draft-preservation-on-switch scenario 1', solve('draft-preservation-on-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), {'a':N,'b':2})
check('draft-preservation-on-switch scenario 2', solve('draft-preservation-on-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), {'a':0})
check('draft-preservation-on-switch scenario 3', solve('draft-preservation-on-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), {})
check('draft-preservation-on-switch scenario 4', solve('draft-preservation-on-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), {'b':None})
check('draft-preservation-on-switch scenario 5', solve('draft-preservation-on-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), {'b':False})
check('draft-preservation-on-switch scenario 6', solve('draft-preservation-on-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), {'a':N})
check('workspace-route-rewrite scenario 1', solve('workspace-route-rewrite', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), '/b/doc')
check('workspace-route-rewrite scenario 2', solve('workspace-route-rewrite', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), '/a')
check('workspace-route-rewrite scenario 3', solve('workspace-route-rewrite', ('a','c',{},[],[('a','p')],'/a/doc',[])), '/c/doc')
check('workspace-route-rewrite scenario 4', solve('workspace-route-rewrite', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), '/a')
check('workspace-route-rewrite scenario 5', solve('workspace-route-rewrite', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), '/shared')
check('workspace-route-rewrite scenario 6', solve('workspace-route-rewrite', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), '/b')
check('same-workspace-no-switch scenario 1', solve('same-workspace-no-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('same-workspace-no-switch scenario 2', solve('same-workspace-no-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), False)
check('same-workspace-no-switch scenario 3', solve('same-workspace-no-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), True)
check('same-workspace-no-switch scenario 4', solve('same-workspace-no-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('same-workspace-no-switch scenario 5', solve('same-workspace-no-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('same-workspace-no-switch scenario 6', solve('same-workspace-no-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('resource-scope-key scenario 1', solve('resource-scope-key', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('resource-scope-key scenario 2', solve('resource-scope-key', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [('a','x')])
check('resource-scope-key scenario 3', solve('resource-scope-key', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('resource-scope-key scenario 4', solve('resource-scope-key', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('resource-scope-key scenario 5', solve('resource-scope-key', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('resource-scope-key scenario 6', solve('resource-scope-key', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('forbidden-switch-retains-owner scenario 1', solve('forbidden-switch-retains-owner', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 2', solve('forbidden-switch-retains-owner', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 'a')
check('forbidden-switch-retains-owner scenario 3', solve('forbidden-switch-retains-owner', ('a','c',{},[],[('a','p')],'/a/doc',[])), 'a')
check('forbidden-switch-retains-owner scenario 4', solve('forbidden-switch-retains-owner', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), 'a')
check('forbidden-switch-retains-owner scenario 5', solve('forbidden-switch-retains-owner', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 6', solve('forbidden-switch-retains-owner', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), 'b')
check('pending-other-workspaces scenario 1', solve('pending-other-workspaces', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','q')])
check('pending-other-workspaces scenario 2', solve('pending-other-workspaces', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('pending-other-workspaces scenario 3', solve('pending-other-workspaces', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('pending-other-workspaces scenario 4', solve('pending-other-workspaces', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('pending-other-workspaces scenario 5', solve('pending-other-workspaces', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','p')])
check('pending-other-workspaces scenario 6', solve('pending-other-workspaces', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['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:
Outgoing resource detach.

Workspace switches preserve each workspace draft, detach only outgoing subscriptions and requests, retain unrelated workspace work, rewrite only the old route prefix, and keep the old workspace if access is not allowed. Operation outgoing-resource-detach 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):
    old, new, drafts, resources, pending, location, allowed = s
    if operation == 'workspace-draft-selection':
        return drafts.get(new)
    if operation == 'outgoing-resource-detach':
        return [(w,k) for w,k in resources if w!=old]
    if operation == 'outgoing-request-cancel':
        return [k for w,k in pending]
    if operation == 'switch-authorization':
        return new in allowed
    if operation == 'draft-preservation-on-switch':
        return dict(drafts)
    if operation == 'workspace-route-rewrite':
        return '/'+new+location[len('/'+old):] if location=='/'+old or location.startswith('/'+old+'/') else location
    if operation == 'same-workspace-no-switch':
        return old!=new
    if operation == 'resource-scope-key':
        return [(new,k) for w,k in resources if w==new]
    if operation == 'forbidden-switch-retains-owner':
        return new if new in allowed else old
    if operation == 'pending-other-workspaces':
        return [(w,k) for w,k in pending if w!=old]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('workspace-draft-selection scenario 1', solve('workspace-draft-selection', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 2)
check('workspace-draft-selection scenario 2', solve('workspace-draft-selection', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 0)
check('workspace-draft-selection scenario 3', solve('workspace-draft-selection', ('a','c',{},[],[('a','p')],'/a/doc',[])), None)
check('workspace-draft-selection scenario 4', solve('workspace-draft-selection', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), None)
check('workspace-draft-selection scenario 5', solve('workspace-draft-selection', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), False)
check('workspace-draft-selection scenario 6', solve('workspace-draft-selection', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), None)
check('outgoing-resource-detach scenario 1', solve('outgoing-resource-detach', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('outgoing-resource-detach scenario 2', solve('outgoing-resource-detach', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-resource-detach scenario 3', solve('outgoing-resource-detach', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('outgoing-resource-detach scenario 4', solve('outgoing-resource-detach', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-resource-detach scenario 5', solve('outgoing-resource-detach', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','x')])
check('outgoing-resource-detach scenario 6', solve('outgoing-resource-detach', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('outgoing-request-cancel scenario 1', solve('outgoing-request-cancel', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), ['p'])
check('outgoing-request-cancel scenario 2', solve('outgoing-request-cancel', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-request-cancel scenario 3', solve('outgoing-request-cancel', ('a','c',{},[],[('a','p')],'/a/doc',[])), ['p'])
check('outgoing-request-cancel scenario 4', solve('outgoing-request-cancel', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-request-cancel scenario 5', solve('outgoing-request-cancel', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('outgoing-request-cancel scenario 6', solve('outgoing-request-cancel', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), ['p','q'])
check('switch-authorization scenario 1', solve('switch-authorization', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('switch-authorization scenario 2', solve('switch-authorization', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), True)
check('switch-authorization scenario 3', solve('switch-authorization', ('a','c',{},[],[('a','p')],'/a/doc',[])), False)
check('switch-authorization scenario 4', solve('switch-authorization', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('switch-authorization scenario 5', solve('switch-authorization', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('switch-authorization scenario 6', solve('switch-authorization', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('draft-preservation-on-switch scenario 1', solve('draft-preservation-on-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), {'a':N,'b':2})
check('draft-preservation-on-switch scenario 2', solve('draft-preservation-on-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), {'a':0})
check('draft-preservation-on-switch scenario 3', solve('draft-preservation-on-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), {})
check('draft-preservation-on-switch scenario 4', solve('draft-preservation-on-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), {'b':None})
check('draft-preservation-on-switch scenario 5', solve('draft-preservation-on-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), {'b':False})
check('draft-preservation-on-switch scenario 6', solve('draft-preservation-on-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), {'a':N})
check('workspace-route-rewrite scenario 1', solve('workspace-route-rewrite', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), '/b/doc')
check('workspace-route-rewrite scenario 2', solve('workspace-route-rewrite', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), '/a')
check('workspace-route-rewrite scenario 3', solve('workspace-route-rewrite', ('a','c',{},[],[('a','p')],'/a/doc',[])), '/c/doc')
check('workspace-route-rewrite scenario 4', solve('workspace-route-rewrite', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), '/a')
check('workspace-route-rewrite scenario 5', solve('workspace-route-rewrite', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), '/shared')
check('workspace-route-rewrite scenario 6', solve('workspace-route-rewrite', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), '/b')
check('same-workspace-no-switch scenario 1', solve('same-workspace-no-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('same-workspace-no-switch scenario 2', solve('same-workspace-no-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), False)
check('same-workspace-no-switch scenario 3', solve('same-workspace-no-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), True)
check('same-workspace-no-switch scenario 4', solve('same-workspace-no-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('same-workspace-no-switch scenario 5', solve('same-workspace-no-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('same-workspace-no-switch scenario 6', solve('same-workspace-no-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('resource-scope-key scenario 1', solve('resource-scope-key', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('resource-scope-key scenario 2', solve('resource-scope-key', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [('a','x')])
check('resource-scope-key scenario 3', solve('resource-scope-key', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('resource-scope-key scenario 4', solve('resource-scope-key', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('resource-scope-key scenario 5', solve('resource-scope-key', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('resource-scope-key scenario 6', solve('resource-scope-key', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('forbidden-switch-retains-owner scenario 1', solve('forbidden-switch-retains-owner', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 2', solve('forbidden-switch-retains-owner', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 'a')
check('forbidden-switch-retains-owner scenario 3', solve('forbidden-switch-retains-owner', ('a','c',{},[],[('a','p')],'/a/doc',[])), 'a')
check('forbidden-switch-retains-owner scenario 4', solve('forbidden-switch-retains-owner', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), 'a')
check('forbidden-switch-retains-owner scenario 5', solve('forbidden-switch-retains-owner', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 6', solve('forbidden-switch-retains-owner', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), 'b')
check('pending-other-workspaces scenario 1', solve('pending-other-workspaces', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','q')])
check('pending-other-workspaces scenario 2', solve('pending-other-workspaces', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('pending-other-workspaces scenario 3', solve('pending-other-workspaces', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('pending-other-workspaces scenario 4', solve('pending-other-workspaces', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('pending-other-workspaces scenario 5', solve('pending-other-workspaces', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','p')])
check('pending-other-workspaces scenario 6', solve('pending-other-workspaces', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['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(operation, s):
    old, new, drafts, resources, pending, location, allowed = s
    if operation == 'workspace-draft-selection':
        return drafts.get(new)
    if operation == 'outgoing-resource-detach':
        return [(w,k) for w,k in resources if w!=old]
    if operation == 'outgoing-request-cancel':
        return [k for w,k in pending if w==old][:1]
    if operation == 'switch-authorization':
        return new in allowed
    if operation == 'draft-preservation-on-switch':
        return dict(drafts)
    if operation == 'workspace-route-rewrite':
        return '/'+new+location[len('/'+old):] if location=='/'+old or location.startswith('/'+old+'/') else location
    if operation == 'same-workspace-no-switch':
        return old!=new
    if operation == 'resource-scope-key':
        return [(new,k) for w,k in resources if w==new]
    if operation == 'forbidden-switch-retains-owner':
        return new if new in allowed else old
    if operation == 'pending-other-workspaces':
        return [(w,k) for w,k in pending if w!=old]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('workspace-draft-selection scenario 1', solve('workspace-draft-selection', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 2)
check('workspace-draft-selection scenario 2', solve('workspace-draft-selection', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 0)
check('workspace-draft-selection scenario 3', solve('workspace-draft-selection', ('a','c',{},[],[('a','p')],'/a/doc',[])), None)
check('workspace-draft-selection scenario 4', solve('workspace-draft-selection', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), None)
check('workspace-draft-selection scenario 5', solve('workspace-draft-selection', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), False)
check('workspace-draft-selection scenario 6', solve('workspace-draft-selection', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), None)
check('outgoing-resource-detach scenario 1', solve('outgoing-resource-detach', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('outgoing-resource-detach scenario 2', solve('outgoing-resource-detach', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-resource-detach scenario 3', solve('outgoing-resource-detach', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('outgoing-resource-detach scenario 4', solve('outgoing-resource-detach', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-resource-detach scenario 5', solve('outgoing-resource-detach', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','x')])
check('outgoing-resource-detach scenario 6', solve('outgoing-resource-detach', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('outgoing-request-cancel scenario 1', solve('outgoing-request-cancel', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), ['p'])
check('outgoing-request-cancel scenario 2', solve('outgoing-request-cancel', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-request-cancel scenario 3', solve('outgoing-request-cancel', ('a','c',{},[],[('a','p')],'/a/doc',[])), ['p'])
check('outgoing-request-cancel scenario 4', solve('outgoing-request-cancel', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-request-cancel scenario 5', solve('outgoing-request-cancel', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('outgoing-request-cancel scenario 6', solve('outgoing-request-cancel', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), ['p','q'])
check('switch-authorization scenario 1', solve('switch-authorization', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('switch-authorization scenario 2', solve('switch-authorization', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), True)
check('switch-authorization scenario 3', solve('switch-authorization', ('a','c',{},[],[('a','p')],'/a/doc',[])), False)
check('switch-authorization scenario 4', solve('switch-authorization', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('switch-authorization scenario 5', solve('switch-authorization', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('switch-authorization scenario 6', solve('switch-authorization', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('draft-preservation-on-switch scenario 1', solve('draft-preservation-on-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), {'a':N,'b':2})
check('draft-preservation-on-switch scenario 2', solve('draft-preservation-on-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), {'a':0})
check('draft-preservation-on-switch scenario 3', solve('draft-preservation-on-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), {})
check('draft-preservation-on-switch scenario 4', solve('draft-preservation-on-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), {'b':None})
check('draft-preservation-on-switch scenario 5', solve('draft-preservation-on-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), {'b':False})
check('draft-preservation-on-switch scenario 6', solve('draft-preservation-on-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), {'a':N})
check('workspace-route-rewrite scenario 1', solve('workspace-route-rewrite', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), '/b/doc')
check('workspace-route-rewrite scenario 2', solve('workspace-route-rewrite', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), '/a')
check('workspace-route-rewrite scenario 3', solve('workspace-route-rewrite', ('a','c',{},[],[('a','p')],'/a/doc',[])), '/c/doc')
check('workspace-route-rewrite scenario 4', solve('workspace-route-rewrite', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), '/a')
check('workspace-route-rewrite scenario 5', solve('workspace-route-rewrite', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), '/shared')
check('workspace-route-rewrite scenario 6', solve('workspace-route-rewrite', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), '/b')
check('same-workspace-no-switch scenario 1', solve('same-workspace-no-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('same-workspace-no-switch scenario 2', solve('same-workspace-no-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), False)
check('same-workspace-no-switch scenario 3', solve('same-workspace-no-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), True)
check('same-workspace-no-switch scenario 4', solve('same-workspace-no-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('same-workspace-no-switch scenario 5', solve('same-workspace-no-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('same-workspace-no-switch scenario 6', solve('same-workspace-no-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('resource-scope-key scenario 1', solve('resource-scope-key', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('resource-scope-key scenario 2', solve('resource-scope-key', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [('a','x')])
check('resource-scope-key scenario 3', solve('resource-scope-key', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('resource-scope-key scenario 4', solve('resource-scope-key', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('resource-scope-key scenario 5', solve('resource-scope-key', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('resource-scope-key scenario 6', solve('resource-scope-key', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('forbidden-switch-retains-owner scenario 1', solve('forbidden-switch-retains-owner', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 2', solve('forbidden-switch-retains-owner', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 'a')
check('forbidden-switch-retains-owner scenario 3', solve('forbidden-switch-retains-owner', ('a','c',{},[],[('a','p')],'/a/doc',[])), 'a')
check('forbidden-switch-retains-owner scenario 4', solve('forbidden-switch-retains-owner', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), 'a')
check('forbidden-switch-retains-owner scenario 5', solve('forbidden-switch-retains-owner', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 6', solve('forbidden-switch-retains-owner', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), 'b')
check('pending-other-workspaces scenario 1', solve('pending-other-workspaces', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','q')])
check('pending-other-workspaces scenario 2', solve('pending-other-workspaces', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('pending-other-workspaces scenario 3', solve('pending-other-workspaces', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('pending-other-workspaces scenario 4', solve('pending-other-workspaces', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('pending-other-workspaces scenario 5', solve('pending-other-workspaces', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','p')])
check('pending-other-workspaces scenario 6', solve('pending-other-workspaces', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['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:
Outgoing request cancel.

Workspace switches preserve each workspace draft, detach only outgoing subscriptions and requests, retain unrelated workspace work, rewrite only the old route prefix, and keep the old workspace if access is not allowed. Operation outgoing-request-cancel 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):
    old, new, drafts, resources, pending, location, allowed = s
    if operation == 'workspace-draft-selection':
        return drafts.get(new)
    if operation == 'outgoing-resource-detach':
        return [(w,k) for w,k in resources if w!=old]
    if operation == 'outgoing-request-cancel':
        return [k for w,k in pending if w==old]
    if operation == 'switch-authorization':
        return True
    if operation == 'draft-preservation-on-switch':
        return dict(drafts)
    if operation == 'workspace-route-rewrite':
        return '/'+new+location[len('/'+old):] if location=='/'+old or location.startswith('/'+old+'/') else location
    if operation == 'same-workspace-no-switch':
        return old!=new
    if operation == 'resource-scope-key':
        return [(new,k) for w,k in resources if w==new]
    if operation == 'forbidden-switch-retains-owner':
        return new if new in allowed else old
    if operation == 'pending-other-workspaces':
        return [(w,k) for w,k in pending if w!=old]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('workspace-draft-selection scenario 1', solve('workspace-draft-selection', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 2)
check('workspace-draft-selection scenario 2', solve('workspace-draft-selection', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 0)
check('workspace-draft-selection scenario 3', solve('workspace-draft-selection', ('a','c',{},[],[('a','p')],'/a/doc',[])), None)
check('workspace-draft-selection scenario 4', solve('workspace-draft-selection', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), None)
check('workspace-draft-selection scenario 5', solve('workspace-draft-selection', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), False)
check('workspace-draft-selection scenario 6', solve('workspace-draft-selection', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), None)
check('outgoing-resource-detach scenario 1', solve('outgoing-resource-detach', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('outgoing-resource-detach scenario 2', solve('outgoing-resource-detach', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-resource-detach scenario 3', solve('outgoing-resource-detach', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('outgoing-resource-detach scenario 4', solve('outgoing-resource-detach', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-resource-detach scenario 5', solve('outgoing-resource-detach', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','x')])
check('outgoing-resource-detach scenario 6', solve('outgoing-resource-detach', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('outgoing-request-cancel scenario 1', solve('outgoing-request-cancel', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), ['p'])
check('outgoing-request-cancel scenario 2', solve('outgoing-request-cancel', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-request-cancel scenario 3', solve('outgoing-request-cancel', ('a','c',{},[],[('a','p')],'/a/doc',[])), ['p'])
check('outgoing-request-cancel scenario 4', solve('outgoing-request-cancel', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-request-cancel scenario 5', solve('outgoing-request-cancel', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('outgoing-request-cancel scenario 6', solve('outgoing-request-cancel', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), ['p','q'])
check('switch-authorization scenario 1', solve('switch-authorization', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('switch-authorization scenario 2', solve('switch-authorization', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), True)
check('switch-authorization scenario 3', solve('switch-authorization', ('a','c',{},[],[('a','p')],'/a/doc',[])), False)
check('switch-authorization scenario 4', solve('switch-authorization', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('switch-authorization scenario 5', solve('switch-authorization', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('switch-authorization scenario 6', solve('switch-authorization', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('draft-preservation-on-switch scenario 1', solve('draft-preservation-on-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), {'a':N,'b':2})
check('draft-preservation-on-switch scenario 2', solve('draft-preservation-on-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), {'a':0})
check('draft-preservation-on-switch scenario 3', solve('draft-preservation-on-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), {})
check('draft-preservation-on-switch scenario 4', solve('draft-preservation-on-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), {'b':None})
check('draft-preservation-on-switch scenario 5', solve('draft-preservation-on-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), {'b':False})
check('draft-preservation-on-switch scenario 6', solve('draft-preservation-on-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), {'a':N})
check('workspace-route-rewrite scenario 1', solve('workspace-route-rewrite', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), '/b/doc')
check('workspace-route-rewrite scenario 2', solve('workspace-route-rewrite', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), '/a')
check('workspace-route-rewrite scenario 3', solve('workspace-route-rewrite', ('a','c',{},[],[('a','p')],'/a/doc',[])), '/c/doc')
check('workspace-route-rewrite scenario 4', solve('workspace-route-rewrite', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), '/a')
check('workspace-route-rewrite scenario 5', solve('workspace-route-rewrite', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), '/shared')
check('workspace-route-rewrite scenario 6', solve('workspace-route-rewrite', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), '/b')
check('same-workspace-no-switch scenario 1', solve('same-workspace-no-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('same-workspace-no-switch scenario 2', solve('same-workspace-no-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), False)
check('same-workspace-no-switch scenario 3', solve('same-workspace-no-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), True)
check('same-workspace-no-switch scenario 4', solve('same-workspace-no-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('same-workspace-no-switch scenario 5', solve('same-workspace-no-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('same-workspace-no-switch scenario 6', solve('same-workspace-no-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('resource-scope-key scenario 1', solve('resource-scope-key', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('resource-scope-key scenario 2', solve('resource-scope-key', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [('a','x')])
check('resource-scope-key scenario 3', solve('resource-scope-key', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('resource-scope-key scenario 4', solve('resource-scope-key', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('resource-scope-key scenario 5', solve('resource-scope-key', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('resource-scope-key scenario 6', solve('resource-scope-key', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('forbidden-switch-retains-owner scenario 1', solve('forbidden-switch-retains-owner', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 2', solve('forbidden-switch-retains-owner', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 'a')
check('forbidden-switch-retains-owner scenario 3', solve('forbidden-switch-retains-owner', ('a','c',{},[],[('a','p')],'/a/doc',[])), 'a')
check('forbidden-switch-retains-owner scenario 4', solve('forbidden-switch-retains-owner', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), 'a')
check('forbidden-switch-retains-owner scenario 5', solve('forbidden-switch-retains-owner', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 6', solve('forbidden-switch-retains-owner', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), 'b')
check('pending-other-workspaces scenario 1', solve('pending-other-workspaces', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','q')])
check('pending-other-workspaces scenario 2', solve('pending-other-workspaces', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('pending-other-workspaces scenario 3', solve('pending-other-workspaces', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('pending-other-workspaces scenario 4', solve('pending-other-workspaces', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('pending-other-workspaces scenario 5', solve('pending-other-workspaces', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','p')])
check('pending-other-workspaces scenario 6', solve('pending-other-workspaces', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['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(operation, s):
    old, new, drafts, resources, pending, location, allowed = s
    if operation == 'workspace-draft-selection':
        return drafts.get(new)
    if operation == 'outgoing-resource-detach':
        return [(w,k) for w,k in resources if w!=old]
    if operation == 'outgoing-request-cancel':
        return [k for w,k in pending if w==old]
    if operation == 'switch-authorization':
        return old in allowed
    if operation == 'draft-preservation-on-switch':
        return dict(drafts)
    if operation == 'workspace-route-rewrite':
        return '/'+new+location[len('/'+old):] if location=='/'+old or location.startswith('/'+old+'/') else location
    if operation == 'same-workspace-no-switch':
        return old!=new
    if operation == 'resource-scope-key':
        return [(new,k) for w,k in resources if w==new]
    if operation == 'forbidden-switch-retains-owner':
        return new if new in allowed else old
    if operation == 'pending-other-workspaces':
        return [(w,k) for w,k in pending if w!=old]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('workspace-draft-selection scenario 1', solve('workspace-draft-selection', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 2)
check('workspace-draft-selection scenario 2', solve('workspace-draft-selection', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 0)
check('workspace-draft-selection scenario 3', solve('workspace-draft-selection', ('a','c',{},[],[('a','p')],'/a/doc',[])), None)
check('workspace-draft-selection scenario 4', solve('workspace-draft-selection', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), None)
check('workspace-draft-selection scenario 5', solve('workspace-draft-selection', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), False)
check('workspace-draft-selection scenario 6', solve('workspace-draft-selection', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), None)
check('outgoing-resource-detach scenario 1', solve('outgoing-resource-detach', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('outgoing-resource-detach scenario 2', solve('outgoing-resource-detach', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-resource-detach scenario 3', solve('outgoing-resource-detach', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('outgoing-resource-detach scenario 4', solve('outgoing-resource-detach', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-resource-detach scenario 5', solve('outgoing-resource-detach', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','x')])
check('outgoing-resource-detach scenario 6', solve('outgoing-resource-detach', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('outgoing-request-cancel scenario 1', solve('outgoing-request-cancel', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), ['p'])
check('outgoing-request-cancel scenario 2', solve('outgoing-request-cancel', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('outgoing-request-cancel scenario 3', solve('outgoing-request-cancel', ('a','c',{},[],[('a','p')],'/a/doc',[])), ['p'])
check('outgoing-request-cancel scenario 4', solve('outgoing-request-cancel', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('outgoing-request-cancel scenario 5', solve('outgoing-request-cancel', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('outgoing-request-cancel scenario 6', solve('outgoing-request-cancel', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), ['p','q'])
check('switch-authorization scenario 1', solve('switch-authorization', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('switch-authorization scenario 2', solve('switch-authorization', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), True)
check('switch-authorization scenario 3', solve('switch-authorization', ('a','c',{},[],[('a','p')],'/a/doc',[])), False)
check('switch-authorization scenario 4', solve('switch-authorization', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('switch-authorization scenario 5', solve('switch-authorization', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('switch-authorization scenario 6', solve('switch-authorization', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('draft-preservation-on-switch scenario 1', solve('draft-preservation-on-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), {'a':N,'b':2})
check('draft-preservation-on-switch scenario 2', solve('draft-preservation-on-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), {'a':0})
check('draft-preservation-on-switch scenario 3', solve('draft-preservation-on-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), {})
check('draft-preservation-on-switch scenario 4', solve('draft-preservation-on-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), {'b':None})
check('draft-preservation-on-switch scenario 5', solve('draft-preservation-on-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), {'b':False})
check('draft-preservation-on-switch scenario 6', solve('draft-preservation-on-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), {'a':N})
check('workspace-route-rewrite scenario 1', solve('workspace-route-rewrite', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), '/b/doc')
check('workspace-route-rewrite scenario 2', solve('workspace-route-rewrite', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), '/a')
check('workspace-route-rewrite scenario 3', solve('workspace-route-rewrite', ('a','c',{},[],[('a','p')],'/a/doc',[])), '/c/doc')
check('workspace-route-rewrite scenario 4', solve('workspace-route-rewrite', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), '/a')
check('workspace-route-rewrite scenario 5', solve('workspace-route-rewrite', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), '/shared')
check('workspace-route-rewrite scenario 6', solve('workspace-route-rewrite', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), '/b')
check('same-workspace-no-switch scenario 1', solve('same-workspace-no-switch', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), True)
check('same-workspace-no-switch scenario 2', solve('same-workspace-no-switch', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), False)
check('same-workspace-no-switch scenario 3', solve('same-workspace-no-switch', ('a','c',{},[],[('a','p')],'/a/doc',[])), True)
check('same-workspace-no-switch scenario 4', solve('same-workspace-no-switch', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), True)
check('same-workspace-no-switch scenario 5', solve('same-workspace-no-switch', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), True)
check('same-workspace-no-switch scenario 6', solve('same-workspace-no-switch', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), True)
check('resource-scope-key scenario 1', solve('resource-scope-key', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','y')])
check('resource-scope-key scenario 2', solve('resource-scope-key', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [('a','x')])
check('resource-scope-key scenario 3', solve('resource-scope-key', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('resource-scope-key scenario 4', solve('resource-scope-key', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('resource-scope-key scenario 5', solve('resource-scope-key', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [])
check('resource-scope-key scenario 6', solve('resource-scope-key', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), [])
check('forbidden-switch-retains-owner scenario 1', solve('forbidden-switch-retains-owner', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 2', solve('forbidden-switch-retains-owner', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), 'a')
check('forbidden-switch-retains-owner scenario 3', solve('forbidden-switch-retains-owner', ('a','c',{},[],[('a','p')],'/a/doc',[])), 'a')
check('forbidden-switch-retains-owner scenario 4', solve('forbidden-switch-retains-owner', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), 'a')
check('forbidden-switch-retains-owner scenario 5', solve('forbidden-switch-retains-owner', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), 'b')
check('forbidden-switch-retains-owner scenario 6', solve('forbidden-switch-retains-owner', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['b'])), 'b')
check('pending-other-workspaces scenario 1', solve('pending-other-workspaces', ('a','b',{'a':N,'b':2},[('a','x'),('b','y')],[('a','p'),('b','q')],'/a/doc',['b'])), [('b','q')])
check('pending-other-workspaces scenario 2', solve('pending-other-workspaces', ('a','a',{'a':0},[('a','x')],[], '/a', ['a'])), [])
check('pending-other-workspaces scenario 3', solve('pending-other-workspaces', ('a','c',{},[],[('a','p')],'/a/doc',[])), [])
check('pending-other-workspaces scenario 4', solve('pending-other-workspaces', ('b','a',{'b':None},[('b','x'),('b','y')],[], '/b', ['a','b'])), [])
check('pending-other-workspaces scenario 5', solve('pending-other-workspaces', ('a','b',{'b':False},[('c','x')],[('c','p')],'/shared',['b'])), [('c','p')])
check('pending-other-workspaces scenario 6', solve('pending-other-workspaces', ('a','b',{'a':N},[],[('a','p'),('a','q')],'/a',['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:
Switch authorization.

Workspace switches preserve each workspace draft, detach only outgoing subscriptions and requests, retain unrelated workspace work, rewrite only the old route prefix, and keep the old workspace if access is not allowed. Operation switch-authorization has the six explicit input/output oracles below.

split: open-access