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

N = 1
observations = []
def solve(operation, s):
    roots, owner, target, portals, event_path, disposed = s
    if operation == 'portal-logical-owner':
        return portals.get(event_path[0]) if event_path and event_path[0] in portals else next((r for r,nodes in roots.items() if event_path and event_path[0] in nodes),None)
    if operation == 'root-disposal-isolation':
        return {r:nodes for r,nodes in roots.items() if r not in disposed}
    if operation == 'owned-portal-cleanup':
        return [p for p,r in portals.items() if r in disposed]
    if operation == 'physical-container-membership':
        return target in roots.get(owner,[])
    if operation == 'event-path-deduplication':
        return list(dict.fromkeys(event_path))
    if operation == 'disposed-owner-no-delivery':
        return owner in roots and owner not in disposed
    if operation == 'portal-host-root-distinction':
        return list(portals)
    if operation == 'unrelated-roots-retention':
        return [r for r in roots if r!=owner]
    if operation == 'root-local-node-count':
        return len(roots.get(owner,[]))
    if operation == 'missing-host-no-implicit-root':
        return next((r for r,nodes in roots.items() if target in nodes),None)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('portal-logical-owner scenario 1', solve('portal-logical-owner', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r1')
check('portal-logical-owner scenario 2', solve('portal-logical-owner', ({},'r1','a',{},[],[],)), None)
check('portal-logical-owner scenario 3', solve('portal-logical-owner', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('portal-logical-owner scenario 4', solve('portal-logical-owner', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('portal-logical-owner scenario 5', solve('portal-logical-owner', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 'r1')
check('portal-logical-owner scenario 6', solve('portal-logical-owner', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
check('root-disposal-isolation scenario 1', solve('root-disposal-isolation', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), {'r1':['a','b'],'r2':['c']})
check('root-disposal-isolation scenario 2', solve('root-disposal-isolation', ({},'r1','a',{},[],[],)), {})
check('root-disposal-isolation scenario 3', solve('root-disposal-isolation', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), {})
check('root-disposal-isolation scenario 4', solve('root-disposal-isolation', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), {'r1':['a'],'r2':['b']})
check('root-disposal-isolation scenario 5', solve('root-disposal-isolation', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), {'r1':['a']})
check('root-disposal-isolation scenario 6', solve('root-disposal-isolation', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), {'r1':['a']*N})
check('owned-portal-cleanup scenario 1', solve('owned-portal-cleanup', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), [])
check('owned-portal-cleanup scenario 2', solve('owned-portal-cleanup', ({},'r1','a',{},[],[],)), [])
check('owned-portal-cleanup scenario 3', solve('owned-portal-cleanup', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('owned-portal-cleanup scenario 4', solve('owned-portal-cleanup', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), [])
check('owned-portal-cleanup scenario 5', solve('owned-portal-cleanup', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('owned-portal-cleanup scenario 6', solve('owned-portal-cleanup', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('physical-container-membership scenario 1', solve('physical-container-membership', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), False)
check('physical-container-membership scenario 2', solve('physical-container-membership', ({},'r1','a',{},[],[],)), False)
check('physical-container-membership scenario 3', solve('physical-container-membership', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), True)
check('physical-container-membership scenario 4', solve('physical-container-membership', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('physical-container-membership scenario 5', solve('physical-container-membership', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), False)
check('physical-container-membership scenario 6', solve('physical-container-membership', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('event-path-deduplication scenario 1', solve('event-path-deduplication', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p','c'])
check('event-path-deduplication scenario 2', solve('event-path-deduplication', ({},'r1','a',{},[],[],)), [])
check('event-path-deduplication scenario 3', solve('event-path-deduplication', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['a'])
check('event-path-deduplication scenario 4', solve('event-path-deduplication', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q','b'])
check('event-path-deduplication scenario 5', solve('event-path-deduplication', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('event-path-deduplication scenario 6', solve('event-path-deduplication', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), ['a'])
check('disposed-owner-no-delivery scenario 1', solve('disposed-owner-no-delivery', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), True)
check('disposed-owner-no-delivery scenario 2', solve('disposed-owner-no-delivery', ({},'r1','a',{},[],[],)), False)
check('disposed-owner-no-delivery scenario 3', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), False)
check('disposed-owner-no-delivery scenario 4', solve('disposed-owner-no-delivery', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('disposed-owner-no-delivery scenario 5', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), True)
check('disposed-owner-no-delivery scenario 6', solve('disposed-owner-no-delivery', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('portal-host-root-distinction scenario 1', solve('portal-host-root-distinction', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p'])
check('portal-host-root-distinction scenario 2', solve('portal-host-root-distinction', ({},'r1','a',{},[],[],)), [])
check('portal-host-root-distinction scenario 3', solve('portal-host-root-distinction', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('portal-host-root-distinction scenario 4', solve('portal-host-root-distinction', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q'])
check('portal-host-root-distinction scenario 5', solve('portal-host-root-distinction', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('portal-host-root-distinction scenario 6', solve('portal-host-root-distinction', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('unrelated-roots-retention scenario 1', solve('unrelated-roots-retention', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['r2'])
check('unrelated-roots-retention scenario 2', solve('unrelated-roots-retention', ({},'r1','a',{},[],[],)), [])
check('unrelated-roots-retention scenario 3', solve('unrelated-roots-retention', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), [])
check('unrelated-roots-retention scenario 4', solve('unrelated-roots-retention', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['r1'])
check('unrelated-roots-retention scenario 5', solve('unrelated-roots-retention', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('unrelated-roots-retention scenario 6', solve('unrelated-roots-retention', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('root-local-node-count scenario 1', solve('root-local-node-count', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 2)
check('root-local-node-count scenario 2', solve('root-local-node-count', ({},'r1','a',{},[],[],)), 0)
check('root-local-node-count scenario 3', solve('root-local-node-count', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 1)
check('root-local-node-count scenario 4', solve('root-local-node-count', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 1)
check('root-local-node-count scenario 5', solve('root-local-node-count', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 1)
check('root-local-node-count scenario 6', solve('root-local-node-count', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), N)
check('missing-host-no-implicit-root scenario 1', solve('missing-host-no-implicit-root', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 2', solve('missing-host-no-implicit-root', ({},'r1','a',{},[],[],)), None)
check('missing-host-no-implicit-root scenario 3', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('missing-host-no-implicit-root scenario 4', solve('missing-host-no-implicit-root', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 5', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), None)
check('missing-host-no-implicit-root scenario 6', solve('missing-host-no-implicit-root', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
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):
    roots, owner, target, portals, event_path, disposed = s
    if operation == 'portal-logical-owner':
        return portals.get(event_path[0]) if event_path and event_path[0] in portals else next((r for r,nodes in roots.items() if event_path and event_path[0] in nodes),None)
    if operation == 'root-disposal-isolation':
        return {r:nodes for r,nodes in roots.items() if r not in disposed}
    if operation == 'owned-portal-cleanup':
        return [p for p,r in portals.items() if r in disposed]
    if operation == 'physical-container-membership':
        return target in roots.get(owner,[])
    if operation == 'event-path-deduplication':
        return list(dict.fromkeys(event_path))
    if operation == 'disposed-owner-no-delivery':
        return owner in roots and owner not in disposed
    if operation == 'portal-host-root-distinction':
        return roots.get(owner,[])
    if operation == 'unrelated-roots-retention':
        return [r for r in roots if r!=owner]
    if operation == 'root-local-node-count':
        return len(roots.get(owner,[]))
    if operation == 'missing-host-no-implicit-root':
        return next((r for r,nodes in roots.items() if target in nodes),None)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('portal-logical-owner scenario 1', solve('portal-logical-owner', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r1')
check('portal-logical-owner scenario 2', solve('portal-logical-owner', ({},'r1','a',{},[],[],)), None)
check('portal-logical-owner scenario 3', solve('portal-logical-owner', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('portal-logical-owner scenario 4', solve('portal-logical-owner', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('portal-logical-owner scenario 5', solve('portal-logical-owner', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 'r1')
check('portal-logical-owner scenario 6', solve('portal-logical-owner', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
check('root-disposal-isolation scenario 1', solve('root-disposal-isolation', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), {'r1':['a','b'],'r2':['c']})
check('root-disposal-isolation scenario 2', solve('root-disposal-isolation', ({},'r1','a',{},[],[],)), {})
check('root-disposal-isolation scenario 3', solve('root-disposal-isolation', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), {})
check('root-disposal-isolation scenario 4', solve('root-disposal-isolation', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), {'r1':['a'],'r2':['b']})
check('root-disposal-isolation scenario 5', solve('root-disposal-isolation', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), {'r1':['a']})
check('root-disposal-isolation scenario 6', solve('root-disposal-isolation', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), {'r1':['a']*N})
check('owned-portal-cleanup scenario 1', solve('owned-portal-cleanup', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), [])
check('owned-portal-cleanup scenario 2', solve('owned-portal-cleanup', ({},'r1','a',{},[],[],)), [])
check('owned-portal-cleanup scenario 3', solve('owned-portal-cleanup', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('owned-portal-cleanup scenario 4', solve('owned-portal-cleanup', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), [])
check('owned-portal-cleanup scenario 5', solve('owned-portal-cleanup', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('owned-portal-cleanup scenario 6', solve('owned-portal-cleanup', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('physical-container-membership scenario 1', solve('physical-container-membership', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), False)
check('physical-container-membership scenario 2', solve('physical-container-membership', ({},'r1','a',{},[],[],)), False)
check('physical-container-membership scenario 3', solve('physical-container-membership', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), True)
check('physical-container-membership scenario 4', solve('physical-container-membership', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('physical-container-membership scenario 5', solve('physical-container-membership', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), False)
check('physical-container-membership scenario 6', solve('physical-container-membership', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('event-path-deduplication scenario 1', solve('event-path-deduplication', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p','c'])
check('event-path-deduplication scenario 2', solve('event-path-deduplication', ({},'r1','a',{},[],[],)), [])
check('event-path-deduplication scenario 3', solve('event-path-deduplication', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['a'])
check('event-path-deduplication scenario 4', solve('event-path-deduplication', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q','b'])
check('event-path-deduplication scenario 5', solve('event-path-deduplication', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('event-path-deduplication scenario 6', solve('event-path-deduplication', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), ['a'])
check('disposed-owner-no-delivery scenario 1', solve('disposed-owner-no-delivery', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), True)
check('disposed-owner-no-delivery scenario 2', solve('disposed-owner-no-delivery', ({},'r1','a',{},[],[],)), False)
check('disposed-owner-no-delivery scenario 3', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), False)
check('disposed-owner-no-delivery scenario 4', solve('disposed-owner-no-delivery', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('disposed-owner-no-delivery scenario 5', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), True)
check('disposed-owner-no-delivery scenario 6', solve('disposed-owner-no-delivery', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('portal-host-root-distinction scenario 1', solve('portal-host-root-distinction', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p'])
check('portal-host-root-distinction scenario 2', solve('portal-host-root-distinction', ({},'r1','a',{},[],[],)), [])
check('portal-host-root-distinction scenario 3', solve('portal-host-root-distinction', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('portal-host-root-distinction scenario 4', solve('portal-host-root-distinction', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q'])
check('portal-host-root-distinction scenario 5', solve('portal-host-root-distinction', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('portal-host-root-distinction scenario 6', solve('portal-host-root-distinction', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('unrelated-roots-retention scenario 1', solve('unrelated-roots-retention', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['r2'])
check('unrelated-roots-retention scenario 2', solve('unrelated-roots-retention', ({},'r1','a',{},[],[],)), [])
check('unrelated-roots-retention scenario 3', solve('unrelated-roots-retention', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), [])
check('unrelated-roots-retention scenario 4', solve('unrelated-roots-retention', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['r1'])
check('unrelated-roots-retention scenario 5', solve('unrelated-roots-retention', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('unrelated-roots-retention scenario 6', solve('unrelated-roots-retention', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('root-local-node-count scenario 1', solve('root-local-node-count', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 2)
check('root-local-node-count scenario 2', solve('root-local-node-count', ({},'r1','a',{},[],[],)), 0)
check('root-local-node-count scenario 3', solve('root-local-node-count', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 1)
check('root-local-node-count scenario 4', solve('root-local-node-count', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 1)
check('root-local-node-count scenario 5', solve('root-local-node-count', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 1)
check('root-local-node-count scenario 6', solve('root-local-node-count', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), N)
check('missing-host-no-implicit-root scenario 1', solve('missing-host-no-implicit-root', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 2', solve('missing-host-no-implicit-root', ({},'r1','a',{},[],[],)), None)
check('missing-host-no-implicit-root scenario 3', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('missing-host-no-implicit-root scenario 4', solve('missing-host-no-implicit-root', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 5', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), None)
check('missing-host-no-implicit-root scenario 6', solve('missing-host-no-implicit-root', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
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:
Portal host root distinction.

Portal event ownership follows the logical root rather than its physical host. Root disposal removes only that root and its owned portals; event paths are deduplicated in order and missing containers do not create roots implicitly. Operation portal-host-root-distinction 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):
    roots, owner, target, portals, event_path, disposed = s
    if operation == 'portal-logical-owner':
        return portals.get(event_path[0]) if event_path and event_path[0] in portals else next((r for r,nodes in roots.items() if event_path and event_path[0] in nodes),None)
    if operation == 'root-disposal-isolation':
        return {r:nodes for r,nodes in roots.items() if r not in disposed}
    if operation == 'owned-portal-cleanup':
        return [p for p,r in portals.items() if r in disposed]
    if operation == 'physical-container-membership':
        return target in roots.get(owner,[])
    if operation == 'event-path-deduplication':
        return list(dict.fromkeys(event_path))
    if operation == 'disposed-owner-no-delivery':
        return owner in roots and owner not in disposed
    if operation == 'portal-host-root-distinction':
        return [p for p,r in portals.items() if r==owner]
    if operation == 'unrelated-roots-retention':
        return []
    if operation == 'root-local-node-count':
        return len(roots.get(owner,[]))
    if operation == 'missing-host-no-implicit-root':
        return next((r for r,nodes in roots.items() if target in nodes),None)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('portal-logical-owner scenario 1', solve('portal-logical-owner', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r1')
check('portal-logical-owner scenario 2', solve('portal-logical-owner', ({},'r1','a',{},[],[],)), None)
check('portal-logical-owner scenario 3', solve('portal-logical-owner', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('portal-logical-owner scenario 4', solve('portal-logical-owner', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('portal-logical-owner scenario 5', solve('portal-logical-owner', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 'r1')
check('portal-logical-owner scenario 6', solve('portal-logical-owner', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
check('root-disposal-isolation scenario 1', solve('root-disposal-isolation', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), {'r1':['a','b'],'r2':['c']})
check('root-disposal-isolation scenario 2', solve('root-disposal-isolation', ({},'r1','a',{},[],[],)), {})
check('root-disposal-isolation scenario 3', solve('root-disposal-isolation', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), {})
check('root-disposal-isolation scenario 4', solve('root-disposal-isolation', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), {'r1':['a'],'r2':['b']})
check('root-disposal-isolation scenario 5', solve('root-disposal-isolation', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), {'r1':['a']})
check('root-disposal-isolation scenario 6', solve('root-disposal-isolation', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), {'r1':['a']*N})
check('owned-portal-cleanup scenario 1', solve('owned-portal-cleanup', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), [])
check('owned-portal-cleanup scenario 2', solve('owned-portal-cleanup', ({},'r1','a',{},[],[],)), [])
check('owned-portal-cleanup scenario 3', solve('owned-portal-cleanup', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('owned-portal-cleanup scenario 4', solve('owned-portal-cleanup', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), [])
check('owned-portal-cleanup scenario 5', solve('owned-portal-cleanup', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('owned-portal-cleanup scenario 6', solve('owned-portal-cleanup', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('physical-container-membership scenario 1', solve('physical-container-membership', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), False)
check('physical-container-membership scenario 2', solve('physical-container-membership', ({},'r1','a',{},[],[],)), False)
check('physical-container-membership scenario 3', solve('physical-container-membership', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), True)
check('physical-container-membership scenario 4', solve('physical-container-membership', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('physical-container-membership scenario 5', solve('physical-container-membership', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), False)
check('physical-container-membership scenario 6', solve('physical-container-membership', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('event-path-deduplication scenario 1', solve('event-path-deduplication', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p','c'])
check('event-path-deduplication scenario 2', solve('event-path-deduplication', ({},'r1','a',{},[],[],)), [])
check('event-path-deduplication scenario 3', solve('event-path-deduplication', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['a'])
check('event-path-deduplication scenario 4', solve('event-path-deduplication', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q','b'])
check('event-path-deduplication scenario 5', solve('event-path-deduplication', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('event-path-deduplication scenario 6', solve('event-path-deduplication', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), ['a'])
check('disposed-owner-no-delivery scenario 1', solve('disposed-owner-no-delivery', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), True)
check('disposed-owner-no-delivery scenario 2', solve('disposed-owner-no-delivery', ({},'r1','a',{},[],[],)), False)
check('disposed-owner-no-delivery scenario 3', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), False)
check('disposed-owner-no-delivery scenario 4', solve('disposed-owner-no-delivery', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('disposed-owner-no-delivery scenario 5', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), True)
check('disposed-owner-no-delivery scenario 6', solve('disposed-owner-no-delivery', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('portal-host-root-distinction scenario 1', solve('portal-host-root-distinction', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p'])
check('portal-host-root-distinction scenario 2', solve('portal-host-root-distinction', ({},'r1','a',{},[],[],)), [])
check('portal-host-root-distinction scenario 3', solve('portal-host-root-distinction', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('portal-host-root-distinction scenario 4', solve('portal-host-root-distinction', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q'])
check('portal-host-root-distinction scenario 5', solve('portal-host-root-distinction', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('portal-host-root-distinction scenario 6', solve('portal-host-root-distinction', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('unrelated-roots-retention scenario 1', solve('unrelated-roots-retention', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['r2'])
check('unrelated-roots-retention scenario 2', solve('unrelated-roots-retention', ({},'r1','a',{},[],[],)), [])
check('unrelated-roots-retention scenario 3', solve('unrelated-roots-retention', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), [])
check('unrelated-roots-retention scenario 4', solve('unrelated-roots-retention', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['r1'])
check('unrelated-roots-retention scenario 5', solve('unrelated-roots-retention', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('unrelated-roots-retention scenario 6', solve('unrelated-roots-retention', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('root-local-node-count scenario 1', solve('root-local-node-count', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 2)
check('root-local-node-count scenario 2', solve('root-local-node-count', ({},'r1','a',{},[],[],)), 0)
check('root-local-node-count scenario 3', solve('root-local-node-count', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 1)
check('root-local-node-count scenario 4', solve('root-local-node-count', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 1)
check('root-local-node-count scenario 5', solve('root-local-node-count', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 1)
check('root-local-node-count scenario 6', solve('root-local-node-count', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), N)
check('missing-host-no-implicit-root scenario 1', solve('missing-host-no-implicit-root', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 2', solve('missing-host-no-implicit-root', ({},'r1','a',{},[],[],)), None)
check('missing-host-no-implicit-root scenario 3', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('missing-host-no-implicit-root scenario 4', solve('missing-host-no-implicit-root', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 5', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), None)
check('missing-host-no-implicit-root scenario 6', solve('missing-host-no-implicit-root', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
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):
    roots, owner, target, portals, event_path, disposed = s
    if operation == 'portal-logical-owner':
        return portals.get(event_path[0]) if event_path and event_path[0] in portals else next((r for r,nodes in roots.items() if event_path and event_path[0] in nodes),None)
    if operation == 'root-disposal-isolation':
        return {r:nodes for r,nodes in roots.items() if r not in disposed}
    if operation == 'owned-portal-cleanup':
        return [p for p,r in portals.items() if r in disposed]
    if operation == 'physical-container-membership':
        return target in roots.get(owner,[])
    if operation == 'event-path-deduplication':
        return list(dict.fromkeys(event_path))
    if operation == 'disposed-owner-no-delivery':
        return owner in roots and owner not in disposed
    if operation == 'portal-host-root-distinction':
        return [p for p,r in portals.items() if r==owner]
    if operation == 'unrelated-roots-retention':
        return list(roots)
    if operation == 'root-local-node-count':
        return len(roots.get(owner,[]))
    if operation == 'missing-host-no-implicit-root':
        return next((r for r,nodes in roots.items() if target in nodes),None)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('portal-logical-owner scenario 1', solve('portal-logical-owner', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r1')
check('portal-logical-owner scenario 2', solve('portal-logical-owner', ({},'r1','a',{},[],[],)), None)
check('portal-logical-owner scenario 3', solve('portal-logical-owner', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('portal-logical-owner scenario 4', solve('portal-logical-owner', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('portal-logical-owner scenario 5', solve('portal-logical-owner', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 'r1')
check('portal-logical-owner scenario 6', solve('portal-logical-owner', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
check('root-disposal-isolation scenario 1', solve('root-disposal-isolation', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), {'r1':['a','b'],'r2':['c']})
check('root-disposal-isolation scenario 2', solve('root-disposal-isolation', ({},'r1','a',{},[],[],)), {})
check('root-disposal-isolation scenario 3', solve('root-disposal-isolation', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), {})
check('root-disposal-isolation scenario 4', solve('root-disposal-isolation', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), {'r1':['a'],'r2':['b']})
check('root-disposal-isolation scenario 5', solve('root-disposal-isolation', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), {'r1':['a']})
check('root-disposal-isolation scenario 6', solve('root-disposal-isolation', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), {'r1':['a']*N})
check('owned-portal-cleanup scenario 1', solve('owned-portal-cleanup', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), [])
check('owned-portal-cleanup scenario 2', solve('owned-portal-cleanup', ({},'r1','a',{},[],[],)), [])
check('owned-portal-cleanup scenario 3', solve('owned-portal-cleanup', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('owned-portal-cleanup scenario 4', solve('owned-portal-cleanup', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), [])
check('owned-portal-cleanup scenario 5', solve('owned-portal-cleanup', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('owned-portal-cleanup scenario 6', solve('owned-portal-cleanup', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('physical-container-membership scenario 1', solve('physical-container-membership', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), False)
check('physical-container-membership scenario 2', solve('physical-container-membership', ({},'r1','a',{},[],[],)), False)
check('physical-container-membership scenario 3', solve('physical-container-membership', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), True)
check('physical-container-membership scenario 4', solve('physical-container-membership', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('physical-container-membership scenario 5', solve('physical-container-membership', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), False)
check('physical-container-membership scenario 6', solve('physical-container-membership', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('event-path-deduplication scenario 1', solve('event-path-deduplication', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p','c'])
check('event-path-deduplication scenario 2', solve('event-path-deduplication', ({},'r1','a',{},[],[],)), [])
check('event-path-deduplication scenario 3', solve('event-path-deduplication', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['a'])
check('event-path-deduplication scenario 4', solve('event-path-deduplication', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q','b'])
check('event-path-deduplication scenario 5', solve('event-path-deduplication', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('event-path-deduplication scenario 6', solve('event-path-deduplication', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), ['a'])
check('disposed-owner-no-delivery scenario 1', solve('disposed-owner-no-delivery', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), True)
check('disposed-owner-no-delivery scenario 2', solve('disposed-owner-no-delivery', ({},'r1','a',{},[],[],)), False)
check('disposed-owner-no-delivery scenario 3', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), False)
check('disposed-owner-no-delivery scenario 4', solve('disposed-owner-no-delivery', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('disposed-owner-no-delivery scenario 5', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), True)
check('disposed-owner-no-delivery scenario 6', solve('disposed-owner-no-delivery', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('portal-host-root-distinction scenario 1', solve('portal-host-root-distinction', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p'])
check('portal-host-root-distinction scenario 2', solve('portal-host-root-distinction', ({},'r1','a',{},[],[],)), [])
check('portal-host-root-distinction scenario 3', solve('portal-host-root-distinction', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('portal-host-root-distinction scenario 4', solve('portal-host-root-distinction', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q'])
check('portal-host-root-distinction scenario 5', solve('portal-host-root-distinction', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('portal-host-root-distinction scenario 6', solve('portal-host-root-distinction', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('unrelated-roots-retention scenario 1', solve('unrelated-roots-retention', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['r2'])
check('unrelated-roots-retention scenario 2', solve('unrelated-roots-retention', ({},'r1','a',{},[],[],)), [])
check('unrelated-roots-retention scenario 3', solve('unrelated-roots-retention', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), [])
check('unrelated-roots-retention scenario 4', solve('unrelated-roots-retention', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['r1'])
check('unrelated-roots-retention scenario 5', solve('unrelated-roots-retention', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('unrelated-roots-retention scenario 6', solve('unrelated-roots-retention', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('root-local-node-count scenario 1', solve('root-local-node-count', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 2)
check('root-local-node-count scenario 2', solve('root-local-node-count', ({},'r1','a',{},[],[],)), 0)
check('root-local-node-count scenario 3', solve('root-local-node-count', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 1)
check('root-local-node-count scenario 4', solve('root-local-node-count', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 1)
check('root-local-node-count scenario 5', solve('root-local-node-count', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 1)
check('root-local-node-count scenario 6', solve('root-local-node-count', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), N)
check('missing-host-no-implicit-root scenario 1', solve('missing-host-no-implicit-root', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 2', solve('missing-host-no-implicit-root', ({},'r1','a',{},[],[],)), None)
check('missing-host-no-implicit-root scenario 3', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('missing-host-no-implicit-root scenario 4', solve('missing-host-no-implicit-root', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 5', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), None)
check('missing-host-no-implicit-root scenario 6', solve('missing-host-no-implicit-root', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
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:
Unrelated roots retention.

Portal event ownership follows the logical root rather than its physical host. Root disposal removes only that root and its owned portals; event paths are deduplicated in order and missing containers do not create roots implicitly. Operation unrelated-roots-retention 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):
    roots, owner, target, portals, event_path, disposed = s
    if operation == 'portal-logical-owner':
        return portals.get(event_path[0]) if event_path and event_path[0] in portals else next((r for r,nodes in roots.items() if event_path and event_path[0] in nodes),None)
    if operation == 'root-disposal-isolation':
        return {r:nodes for r,nodes in roots.items() if r not in disposed}
    if operation == 'owned-portal-cleanup':
        return [p for p,r in portals.items() if r in disposed]
    if operation == 'physical-container-membership':
        return target in roots.get(owner,[])
    if operation == 'event-path-deduplication':
        return list(dict.fromkeys(event_path))
    if operation == 'disposed-owner-no-delivery':
        return owner in roots and owner not in disposed
    if operation == 'portal-host-root-distinction':
        return [p for p,r in portals.items() if r==owner]
    if operation == 'unrelated-roots-retention':
        return [r for r in roots if r!=owner]
    if operation == 'root-local-node-count':
        return sum(len(nodes) for nodes in roots.values())
    if operation == 'missing-host-no-implicit-root':
        return next((r for r,nodes in roots.items() if target in nodes),None)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('portal-logical-owner scenario 1', solve('portal-logical-owner', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r1')
check('portal-logical-owner scenario 2', solve('portal-logical-owner', ({},'r1','a',{},[],[],)), None)
check('portal-logical-owner scenario 3', solve('portal-logical-owner', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('portal-logical-owner scenario 4', solve('portal-logical-owner', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('portal-logical-owner scenario 5', solve('portal-logical-owner', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 'r1')
check('portal-logical-owner scenario 6', solve('portal-logical-owner', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
check('root-disposal-isolation scenario 1', solve('root-disposal-isolation', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), {'r1':['a','b'],'r2':['c']})
check('root-disposal-isolation scenario 2', solve('root-disposal-isolation', ({},'r1','a',{},[],[],)), {})
check('root-disposal-isolation scenario 3', solve('root-disposal-isolation', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), {})
check('root-disposal-isolation scenario 4', solve('root-disposal-isolation', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), {'r1':['a'],'r2':['b']})
check('root-disposal-isolation scenario 5', solve('root-disposal-isolation', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), {'r1':['a']})
check('root-disposal-isolation scenario 6', solve('root-disposal-isolation', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), {'r1':['a']*N})
check('owned-portal-cleanup scenario 1', solve('owned-portal-cleanup', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), [])
check('owned-portal-cleanup scenario 2', solve('owned-portal-cleanup', ({},'r1','a',{},[],[],)), [])
check('owned-portal-cleanup scenario 3', solve('owned-portal-cleanup', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('owned-portal-cleanup scenario 4', solve('owned-portal-cleanup', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), [])
check('owned-portal-cleanup scenario 5', solve('owned-portal-cleanup', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('owned-portal-cleanup scenario 6', solve('owned-portal-cleanup', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('physical-container-membership scenario 1', solve('physical-container-membership', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), False)
check('physical-container-membership scenario 2', solve('physical-container-membership', ({},'r1','a',{},[],[],)), False)
check('physical-container-membership scenario 3', solve('physical-container-membership', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), True)
check('physical-container-membership scenario 4', solve('physical-container-membership', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('physical-container-membership scenario 5', solve('physical-container-membership', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), False)
check('physical-container-membership scenario 6', solve('physical-container-membership', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('event-path-deduplication scenario 1', solve('event-path-deduplication', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p','c'])
check('event-path-deduplication scenario 2', solve('event-path-deduplication', ({},'r1','a',{},[],[],)), [])
check('event-path-deduplication scenario 3', solve('event-path-deduplication', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['a'])
check('event-path-deduplication scenario 4', solve('event-path-deduplication', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q','b'])
check('event-path-deduplication scenario 5', solve('event-path-deduplication', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('event-path-deduplication scenario 6', solve('event-path-deduplication', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), ['a'])
check('disposed-owner-no-delivery scenario 1', solve('disposed-owner-no-delivery', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), True)
check('disposed-owner-no-delivery scenario 2', solve('disposed-owner-no-delivery', ({},'r1','a',{},[],[],)), False)
check('disposed-owner-no-delivery scenario 3', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), False)
check('disposed-owner-no-delivery scenario 4', solve('disposed-owner-no-delivery', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('disposed-owner-no-delivery scenario 5', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), True)
check('disposed-owner-no-delivery scenario 6', solve('disposed-owner-no-delivery', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('portal-host-root-distinction scenario 1', solve('portal-host-root-distinction', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p'])
check('portal-host-root-distinction scenario 2', solve('portal-host-root-distinction', ({},'r1','a',{},[],[],)), [])
check('portal-host-root-distinction scenario 3', solve('portal-host-root-distinction', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('portal-host-root-distinction scenario 4', solve('portal-host-root-distinction', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q'])
check('portal-host-root-distinction scenario 5', solve('portal-host-root-distinction', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('portal-host-root-distinction scenario 6', solve('portal-host-root-distinction', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('unrelated-roots-retention scenario 1', solve('unrelated-roots-retention', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['r2'])
check('unrelated-roots-retention scenario 2', solve('unrelated-roots-retention', ({},'r1','a',{},[],[],)), [])
check('unrelated-roots-retention scenario 3', solve('unrelated-roots-retention', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), [])
check('unrelated-roots-retention scenario 4', solve('unrelated-roots-retention', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['r1'])
check('unrelated-roots-retention scenario 5', solve('unrelated-roots-retention', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('unrelated-roots-retention scenario 6', solve('unrelated-roots-retention', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('root-local-node-count scenario 1', solve('root-local-node-count', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 2)
check('root-local-node-count scenario 2', solve('root-local-node-count', ({},'r1','a',{},[],[],)), 0)
check('root-local-node-count scenario 3', solve('root-local-node-count', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 1)
check('root-local-node-count scenario 4', solve('root-local-node-count', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 1)
check('root-local-node-count scenario 5', solve('root-local-node-count', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 1)
check('root-local-node-count scenario 6', solve('root-local-node-count', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), N)
check('missing-host-no-implicit-root scenario 1', solve('missing-host-no-implicit-root', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 2', solve('missing-host-no-implicit-root', ({},'r1','a',{},[],[],)), None)
check('missing-host-no-implicit-root scenario 3', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('missing-host-no-implicit-root scenario 4', solve('missing-host-no-implicit-root', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 5', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), None)
check('missing-host-no-implicit-root scenario 6', solve('missing-host-no-implicit-root', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
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):
    roots, owner, target, portals, event_path, disposed = s
    if operation == 'portal-logical-owner':
        return portals.get(event_path[0]) if event_path and event_path[0] in portals else next((r for r,nodes in roots.items() if event_path and event_path[0] in nodes),None)
    if operation == 'root-disposal-isolation':
        return {r:nodes for r,nodes in roots.items() if r not in disposed}
    if operation == 'owned-portal-cleanup':
        return [p for p,r in portals.items() if r in disposed]
    if operation == 'physical-container-membership':
        return target in roots.get(owner,[])
    if operation == 'event-path-deduplication':
        return list(dict.fromkeys(event_path))
    if operation == 'disposed-owner-no-delivery':
        return owner in roots and owner not in disposed
    if operation == 'portal-host-root-distinction':
        return [p for p,r in portals.items() if r==owner]
    if operation == 'unrelated-roots-retention':
        return [r for r in roots if r!=owner]
    if operation == 'root-local-node-count':
        return int(owner in roots)
    if operation == 'missing-host-no-implicit-root':
        return next((r for r,nodes in roots.items() if target in nodes),None)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('portal-logical-owner scenario 1', solve('portal-logical-owner', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r1')
check('portal-logical-owner scenario 2', solve('portal-logical-owner', ({},'r1','a',{},[],[],)), None)
check('portal-logical-owner scenario 3', solve('portal-logical-owner', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('portal-logical-owner scenario 4', solve('portal-logical-owner', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('portal-logical-owner scenario 5', solve('portal-logical-owner', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 'r1')
check('portal-logical-owner scenario 6', solve('portal-logical-owner', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
check('root-disposal-isolation scenario 1', solve('root-disposal-isolation', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), {'r1':['a','b'],'r2':['c']})
check('root-disposal-isolation scenario 2', solve('root-disposal-isolation', ({},'r1','a',{},[],[],)), {})
check('root-disposal-isolation scenario 3', solve('root-disposal-isolation', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), {})
check('root-disposal-isolation scenario 4', solve('root-disposal-isolation', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), {'r1':['a'],'r2':['b']})
check('root-disposal-isolation scenario 5', solve('root-disposal-isolation', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), {'r1':['a']})
check('root-disposal-isolation scenario 6', solve('root-disposal-isolation', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), {'r1':['a']*N})
check('owned-portal-cleanup scenario 1', solve('owned-portal-cleanup', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), [])
check('owned-portal-cleanup scenario 2', solve('owned-portal-cleanup', ({},'r1','a',{},[],[],)), [])
check('owned-portal-cleanup scenario 3', solve('owned-portal-cleanup', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('owned-portal-cleanup scenario 4', solve('owned-portal-cleanup', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), [])
check('owned-portal-cleanup scenario 5', solve('owned-portal-cleanup', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('owned-portal-cleanup scenario 6', solve('owned-portal-cleanup', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('physical-container-membership scenario 1', solve('physical-container-membership', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), False)
check('physical-container-membership scenario 2', solve('physical-container-membership', ({},'r1','a',{},[],[],)), False)
check('physical-container-membership scenario 3', solve('physical-container-membership', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), True)
check('physical-container-membership scenario 4', solve('physical-container-membership', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('physical-container-membership scenario 5', solve('physical-container-membership', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), False)
check('physical-container-membership scenario 6', solve('physical-container-membership', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('event-path-deduplication scenario 1', solve('event-path-deduplication', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p','c'])
check('event-path-deduplication scenario 2', solve('event-path-deduplication', ({},'r1','a',{},[],[],)), [])
check('event-path-deduplication scenario 3', solve('event-path-deduplication', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['a'])
check('event-path-deduplication scenario 4', solve('event-path-deduplication', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q','b'])
check('event-path-deduplication scenario 5', solve('event-path-deduplication', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('event-path-deduplication scenario 6', solve('event-path-deduplication', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), ['a'])
check('disposed-owner-no-delivery scenario 1', solve('disposed-owner-no-delivery', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), True)
check('disposed-owner-no-delivery scenario 2', solve('disposed-owner-no-delivery', ({},'r1','a',{},[],[],)), False)
check('disposed-owner-no-delivery scenario 3', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), False)
check('disposed-owner-no-delivery scenario 4', solve('disposed-owner-no-delivery', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('disposed-owner-no-delivery scenario 5', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), True)
check('disposed-owner-no-delivery scenario 6', solve('disposed-owner-no-delivery', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('portal-host-root-distinction scenario 1', solve('portal-host-root-distinction', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p'])
check('portal-host-root-distinction scenario 2', solve('portal-host-root-distinction', ({},'r1','a',{},[],[],)), [])
check('portal-host-root-distinction scenario 3', solve('portal-host-root-distinction', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('portal-host-root-distinction scenario 4', solve('portal-host-root-distinction', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q'])
check('portal-host-root-distinction scenario 5', solve('portal-host-root-distinction', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('portal-host-root-distinction scenario 6', solve('portal-host-root-distinction', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('unrelated-roots-retention scenario 1', solve('unrelated-roots-retention', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['r2'])
check('unrelated-roots-retention scenario 2', solve('unrelated-roots-retention', ({},'r1','a',{},[],[],)), [])
check('unrelated-roots-retention scenario 3', solve('unrelated-roots-retention', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), [])
check('unrelated-roots-retention scenario 4', solve('unrelated-roots-retention', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['r1'])
check('unrelated-roots-retention scenario 5', solve('unrelated-roots-retention', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('unrelated-roots-retention scenario 6', solve('unrelated-roots-retention', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('root-local-node-count scenario 1', solve('root-local-node-count', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 2)
check('root-local-node-count scenario 2', solve('root-local-node-count', ({},'r1','a',{},[],[],)), 0)
check('root-local-node-count scenario 3', solve('root-local-node-count', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 1)
check('root-local-node-count scenario 4', solve('root-local-node-count', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 1)
check('root-local-node-count scenario 5', solve('root-local-node-count', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 1)
check('root-local-node-count scenario 6', solve('root-local-node-count', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), N)
check('missing-host-no-implicit-root scenario 1', solve('missing-host-no-implicit-root', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 2', solve('missing-host-no-implicit-root', ({},'r1','a',{},[],[],)), None)
check('missing-host-no-implicit-root scenario 3', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('missing-host-no-implicit-root scenario 4', solve('missing-host-no-implicit-root', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 5', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), None)
check('missing-host-no-implicit-root scenario 6', solve('missing-host-no-implicit-root', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Root local node count.

Portal event ownership follows the logical root rather than its physical host. Root disposal removes only that root and its owned portals; event paths are deduplicated in order and missing containers do not create roots implicitly. Operation root-local-node-count 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):
    roots, owner, target, portals, event_path, disposed = s
    if operation == 'portal-logical-owner':
        return portals.get(event_path[0]) if event_path and event_path[0] in portals else next((r for r,nodes in roots.items() if event_path and event_path[0] in nodes),None)
    if operation == 'root-disposal-isolation':
        return {r:nodes for r,nodes in roots.items() if r not in disposed}
    if operation == 'owned-portal-cleanup':
        return [p for p,r in portals.items() if r in disposed]
    if operation == 'physical-container-membership':
        return target in roots.get(owner,[])
    if operation == 'event-path-deduplication':
        return list(dict.fromkeys(event_path))
    if operation == 'disposed-owner-no-delivery':
        return owner in roots and owner not in disposed
    if operation == 'portal-host-root-distinction':
        return [p for p,r in portals.items() if r==owner]
    if operation == 'unrelated-roots-retention':
        return [r for r in roots if r!=owner]
    if operation == 'root-local-node-count':
        return len(roots.get(owner,[]))
    if operation == 'missing-host-no-implicit-root':
        return owner
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('portal-logical-owner scenario 1', solve('portal-logical-owner', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r1')
check('portal-logical-owner scenario 2', solve('portal-logical-owner', ({},'r1','a',{},[],[],)), None)
check('portal-logical-owner scenario 3', solve('portal-logical-owner', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('portal-logical-owner scenario 4', solve('portal-logical-owner', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('portal-logical-owner scenario 5', solve('portal-logical-owner', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 'r1')
check('portal-logical-owner scenario 6', solve('portal-logical-owner', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
check('root-disposal-isolation scenario 1', solve('root-disposal-isolation', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), {'r1':['a','b'],'r2':['c']})
check('root-disposal-isolation scenario 2', solve('root-disposal-isolation', ({},'r1','a',{},[],[],)), {})
check('root-disposal-isolation scenario 3', solve('root-disposal-isolation', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), {})
check('root-disposal-isolation scenario 4', solve('root-disposal-isolation', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), {'r1':['a'],'r2':['b']})
check('root-disposal-isolation scenario 5', solve('root-disposal-isolation', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), {'r1':['a']})
check('root-disposal-isolation scenario 6', solve('root-disposal-isolation', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), {'r1':['a']*N})
check('owned-portal-cleanup scenario 1', solve('owned-portal-cleanup', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), [])
check('owned-portal-cleanup scenario 2', solve('owned-portal-cleanup', ({},'r1','a',{},[],[],)), [])
check('owned-portal-cleanup scenario 3', solve('owned-portal-cleanup', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('owned-portal-cleanup scenario 4', solve('owned-portal-cleanup', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), [])
check('owned-portal-cleanup scenario 5', solve('owned-portal-cleanup', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('owned-portal-cleanup scenario 6', solve('owned-portal-cleanup', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('physical-container-membership scenario 1', solve('physical-container-membership', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), False)
check('physical-container-membership scenario 2', solve('physical-container-membership', ({},'r1','a',{},[],[],)), False)
check('physical-container-membership scenario 3', solve('physical-container-membership', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), True)
check('physical-container-membership scenario 4', solve('physical-container-membership', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('physical-container-membership scenario 5', solve('physical-container-membership', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), False)
check('physical-container-membership scenario 6', solve('physical-container-membership', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('event-path-deduplication scenario 1', solve('event-path-deduplication', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p','c'])
check('event-path-deduplication scenario 2', solve('event-path-deduplication', ({},'r1','a',{},[],[],)), [])
check('event-path-deduplication scenario 3', solve('event-path-deduplication', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['a'])
check('event-path-deduplication scenario 4', solve('event-path-deduplication', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q','b'])
check('event-path-deduplication scenario 5', solve('event-path-deduplication', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('event-path-deduplication scenario 6', solve('event-path-deduplication', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), ['a'])
check('disposed-owner-no-delivery scenario 1', solve('disposed-owner-no-delivery', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), True)
check('disposed-owner-no-delivery scenario 2', solve('disposed-owner-no-delivery', ({},'r1','a',{},[],[],)), False)
check('disposed-owner-no-delivery scenario 3', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), False)
check('disposed-owner-no-delivery scenario 4', solve('disposed-owner-no-delivery', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('disposed-owner-no-delivery scenario 5', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), True)
check('disposed-owner-no-delivery scenario 6', solve('disposed-owner-no-delivery', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('portal-host-root-distinction scenario 1', solve('portal-host-root-distinction', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p'])
check('portal-host-root-distinction scenario 2', solve('portal-host-root-distinction', ({},'r1','a',{},[],[],)), [])
check('portal-host-root-distinction scenario 3', solve('portal-host-root-distinction', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('portal-host-root-distinction scenario 4', solve('portal-host-root-distinction', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q'])
check('portal-host-root-distinction scenario 5', solve('portal-host-root-distinction', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('portal-host-root-distinction scenario 6', solve('portal-host-root-distinction', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('unrelated-roots-retention scenario 1', solve('unrelated-roots-retention', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['r2'])
check('unrelated-roots-retention scenario 2', solve('unrelated-roots-retention', ({},'r1','a',{},[],[],)), [])
check('unrelated-roots-retention scenario 3', solve('unrelated-roots-retention', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), [])
check('unrelated-roots-retention scenario 4', solve('unrelated-roots-retention', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['r1'])
check('unrelated-roots-retention scenario 5', solve('unrelated-roots-retention', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('unrelated-roots-retention scenario 6', solve('unrelated-roots-retention', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('root-local-node-count scenario 1', solve('root-local-node-count', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 2)
check('root-local-node-count scenario 2', solve('root-local-node-count', ({},'r1','a',{},[],[],)), 0)
check('root-local-node-count scenario 3', solve('root-local-node-count', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 1)
check('root-local-node-count scenario 4', solve('root-local-node-count', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 1)
check('root-local-node-count scenario 5', solve('root-local-node-count', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 1)
check('root-local-node-count scenario 6', solve('root-local-node-count', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), N)
check('missing-host-no-implicit-root scenario 1', solve('missing-host-no-implicit-root', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 2', solve('missing-host-no-implicit-root', ({},'r1','a',{},[],[],)), None)
check('missing-host-no-implicit-root scenario 3', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('missing-host-no-implicit-root scenario 4', solve('missing-host-no-implicit-root', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 5', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), None)
check('missing-host-no-implicit-root scenario 6', solve('missing-host-no-implicit-root', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
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):
    roots, owner, target, portals, event_path, disposed = s
    if operation == 'portal-logical-owner':
        return portals.get(event_path[0]) if event_path and event_path[0] in portals else next((r for r,nodes in roots.items() if event_path and event_path[0] in nodes),None)
    if operation == 'root-disposal-isolation':
        return {r:nodes for r,nodes in roots.items() if r not in disposed}
    if operation == 'owned-portal-cleanup':
        return [p for p,r in portals.items() if r in disposed]
    if operation == 'physical-container-membership':
        return target in roots.get(owner,[])
    if operation == 'event-path-deduplication':
        return list(dict.fromkeys(event_path))
    if operation == 'disposed-owner-no-delivery':
        return owner in roots and owner not in disposed
    if operation == 'portal-host-root-distinction':
        return [p for p,r in portals.items() if r==owner]
    if operation == 'unrelated-roots-retention':
        return [r for r in roots if r!=owner]
    if operation == 'root-local-node-count':
        return len(roots.get(owner,[]))
    if operation == 'missing-host-no-implicit-root':
        return next(iter(roots),None)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('portal-logical-owner scenario 1', solve('portal-logical-owner', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r1')
check('portal-logical-owner scenario 2', solve('portal-logical-owner', ({},'r1','a',{},[],[],)), None)
check('portal-logical-owner scenario 3', solve('portal-logical-owner', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('portal-logical-owner scenario 4', solve('portal-logical-owner', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('portal-logical-owner scenario 5', solve('portal-logical-owner', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 'r1')
check('portal-logical-owner scenario 6', solve('portal-logical-owner', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
check('root-disposal-isolation scenario 1', solve('root-disposal-isolation', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), {'r1':['a','b'],'r2':['c']})
check('root-disposal-isolation scenario 2', solve('root-disposal-isolation', ({},'r1','a',{},[],[],)), {})
check('root-disposal-isolation scenario 3', solve('root-disposal-isolation', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), {})
check('root-disposal-isolation scenario 4', solve('root-disposal-isolation', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), {'r1':['a'],'r2':['b']})
check('root-disposal-isolation scenario 5', solve('root-disposal-isolation', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), {'r1':['a']})
check('root-disposal-isolation scenario 6', solve('root-disposal-isolation', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), {'r1':['a']*N})
check('owned-portal-cleanup scenario 1', solve('owned-portal-cleanup', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), [])
check('owned-portal-cleanup scenario 2', solve('owned-portal-cleanup', ({},'r1','a',{},[],[],)), [])
check('owned-portal-cleanup scenario 3', solve('owned-portal-cleanup', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('owned-portal-cleanup scenario 4', solve('owned-portal-cleanup', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), [])
check('owned-portal-cleanup scenario 5', solve('owned-portal-cleanup', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('owned-portal-cleanup scenario 6', solve('owned-portal-cleanup', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('physical-container-membership scenario 1', solve('physical-container-membership', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), False)
check('physical-container-membership scenario 2', solve('physical-container-membership', ({},'r1','a',{},[],[],)), False)
check('physical-container-membership scenario 3', solve('physical-container-membership', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), True)
check('physical-container-membership scenario 4', solve('physical-container-membership', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('physical-container-membership scenario 5', solve('physical-container-membership', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), False)
check('physical-container-membership scenario 6', solve('physical-container-membership', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('event-path-deduplication scenario 1', solve('event-path-deduplication', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p','c'])
check('event-path-deduplication scenario 2', solve('event-path-deduplication', ({},'r1','a',{},[],[],)), [])
check('event-path-deduplication scenario 3', solve('event-path-deduplication', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['a'])
check('event-path-deduplication scenario 4', solve('event-path-deduplication', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q','b'])
check('event-path-deduplication scenario 5', solve('event-path-deduplication', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('event-path-deduplication scenario 6', solve('event-path-deduplication', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), ['a'])
check('disposed-owner-no-delivery scenario 1', solve('disposed-owner-no-delivery', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), True)
check('disposed-owner-no-delivery scenario 2', solve('disposed-owner-no-delivery', ({},'r1','a',{},[],[],)), False)
check('disposed-owner-no-delivery scenario 3', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), False)
check('disposed-owner-no-delivery scenario 4', solve('disposed-owner-no-delivery', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), True)
check('disposed-owner-no-delivery scenario 5', solve('disposed-owner-no-delivery', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), True)
check('disposed-owner-no-delivery scenario 6', solve('disposed-owner-no-delivery', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), True)
check('portal-host-root-distinction scenario 1', solve('portal-host-root-distinction', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['p'])
check('portal-host-root-distinction scenario 2', solve('portal-host-root-distinction', ({},'r1','a',{},[],[],)), [])
check('portal-host-root-distinction scenario 3', solve('portal-host-root-distinction', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), ['p'])
check('portal-host-root-distinction scenario 4', solve('portal-host-root-distinction', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['q'])
check('portal-host-root-distinction scenario 5', solve('portal-host-root-distinction', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), ['p'])
check('portal-host-root-distinction scenario 6', solve('portal-host-root-distinction', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('unrelated-roots-retention scenario 1', solve('unrelated-roots-retention', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), ['r2'])
check('unrelated-roots-retention scenario 2', solve('unrelated-roots-retention', ({},'r1','a',{},[],[],)), [])
check('unrelated-roots-retention scenario 3', solve('unrelated-roots-retention', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), [])
check('unrelated-roots-retention scenario 4', solve('unrelated-roots-retention', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), ['r1'])
check('unrelated-roots-retention scenario 5', solve('unrelated-roots-retention', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), [])
check('unrelated-roots-retention scenario 6', solve('unrelated-roots-retention', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), [])
check('root-local-node-count scenario 1', solve('root-local-node-count', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 2)
check('root-local-node-count scenario 2', solve('root-local-node-count', ({},'r1','a',{},[],[],)), 0)
check('root-local-node-count scenario 3', solve('root-local-node-count', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 1)
check('root-local-node-count scenario 4', solve('root-local-node-count', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 1)
check('root-local-node-count scenario 5', solve('root-local-node-count', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), 1)
check('root-local-node-count scenario 6', solve('root-local-node-count', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), N)
check('missing-host-no-implicit-root scenario 1', solve('missing-host-no-implicit-root', ({'r1':['a','b'],'r2':['c']},'r1','c',{'p':'r1'},['p','c'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 2', solve('missing-host-no-implicit-root', ({},'r1','a',{},[],[],)), None)
check('missing-host-no-implicit-root scenario 3', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','a',{'p':'r1'},['a'],['r1'],)), 'r1')
check('missing-host-no-implicit-root scenario 4', solve('missing-host-no-implicit-root', ({'r1':['a'],'r2':['b']},'r2','b',{'p':'r1','q':'r2'},['q','b'],[],)), 'r2')
check('missing-host-no-implicit-root scenario 5', solve('missing-host-no-implicit-root', ({'r1':['a']},'r1','missing',{'p':'r1'},['p'],[],)), None)
check('missing-host-no-implicit-root scenario 6', solve('missing-host-no-implicit-root', ({'r1':['a']*N},'r1','a',{},['a','a'],[],)), 'r1')
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:
Missing host no implicit root.

Portal event ownership follows the logical root rather than its physical host. Root disposal removes only that root and its owned portals; event paths are deduplicated in order and missing containers do not create roots implicitly. Operation missing-host-no-implicit-root has the six explicit input/output oracles below.

split: open-access