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

N = 1
observations = []
def solve(d):
    selfdrop=d['target']==d['source']
    inside=d['placement']=='inside'
    parent=d['target'] if inside else d['parent']
    structural=(d['branch'] if inside else parent is not None)
    partition=inside or d['source_partition']==d['target_partition']
    permission=d['writable'] and (d['copy_allowed'] if d['effect']=='copy' else d['move_allowed'])
    allowed=not selfdrop and structural and partition and permission
    position=d['child_count']+1 if inside else d['target_index']+1+(d['placement']=='after')
    level=d['target_level']+1 if inside else d['target_level']
    effect=d['effect'] if allowed else 'none'
    return [allowed,parent,position,level,effect]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 't', 5, 3, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 'p', 3, 2, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 'p', 2, 2, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 'c', 5, 3, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 't', 5, 3, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 'p', 3, 2, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, None, 2, 2, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 't', 5, 3, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 't', 5, 3, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 'p', 3, 2, 'none'])], 2: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 't', 6, 4, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 'p', 4, 3, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 'p', 3, 3, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 'c', 6, 4, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 't', 6, 4, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 'p', 4, 3, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, None, 3, 3, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 't', 6, 4, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 't', 6, 4, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 'p', 4, 3, 'none'])], 3: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 't', 7, 5, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 'p', 5, 4, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 'p', 4, 4, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 'c', 7, 5, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 't', 7, 5, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 'p', 5, 4, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, None, 4, 4, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 't', 7, 5, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 't', 7, 5, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 'p', 5, 4, 'none'])], 4: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 't', 8, 6, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 'p', 6, 5, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 'p', 5, 5, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 'c', 8, 6, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 't', 8, 6, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 'p', 6, 5, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, None, 5, 5, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 't', 8, 6, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 't', 8, 6, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 'p', 6, 5, 'none'])], 5: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 't', 9, 7, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 'p', 7, 6, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 'p', 6, 6, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 'c', 9, 7, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 't', 9, 7, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 'p', 7, 6, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, None, 6, 6, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 't', 9, 7, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 't', 9, 7, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 'p', 7, 6, 'none'])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    selfdrop=False
    inside=d['placement']=='inside'
    parent=d['target'] if inside else d['parent']
    structural=(d['branch'] if inside else parent is not None)
    partition=inside or d['source_partition']==d['target_partition']
    permission=d['writable'] and (d['copy_allowed'] if d['effect']=='copy' else d['move_allowed'])
    allowed=not selfdrop and structural and partition and permission
    position=d['child_count']+1 if inside else d['target_index']+1+(d['placement']=='after')
    level=d['target_level']+1 if inside else d['target_level']
    effect=d['effect'] if allowed else 'none'
    return [allowed,parent,position,level,effect]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 't', 5, 3, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 'p', 3, 2, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 'p', 2, 2, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 'c', 5, 3, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 't', 5, 3, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 'p', 3, 2, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, None, 2, 2, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 't', 5, 3, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 't', 5, 3, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 'p', 3, 2, 'none'])], 2: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 't', 6, 4, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 'p', 4, 3, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 'p', 3, 3, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 'c', 6, 4, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 't', 6, 4, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 'p', 4, 3, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, None, 3, 3, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 't', 6, 4, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 't', 6, 4, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 'p', 4, 3, 'none'])], 3: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 't', 7, 5, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 'p', 5, 4, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 'p', 4, 4, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 'c', 7, 5, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 't', 7, 5, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 'p', 5, 4, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, None, 4, 4, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 't', 7, 5, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 't', 7, 5, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 'p', 5, 4, 'none'])], 4: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 't', 8, 6, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 'p', 6, 5, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 'p', 5, 5, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 'c', 8, 6, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 't', 8, 6, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 'p', 6, 5, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, None, 5, 5, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 't', 8, 6, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 't', 8, 6, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 'p', 6, 5, 'none'])], 5: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 't', 9, 7, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 'p', 7, 6, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 'p', 6, 6, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 'c', 9, 7, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 't', 9, 7, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 'p', 7, 6, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, None, 6, 6, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 't', 9, 7, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 't', 9, 7, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 'p', 7, 6, 'none'])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
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:
Descendant drop incorrectly escapes self-drop check produces the wrong hierarchical widget state in a regression fixture.

A drag advertises one legal drop location at a time. Inside requires a writable branch; before/after require a parent and same sibling partition. Self and descendant targets are forbidden. Copy needs copy permission. Descriptor includes announced hierarchy level and one-based insertion position.

split: open-access


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

N = 1
observations = []
def solve(d):
    selfdrop=d['target'] in d['closure']
    inside=d['placement']!='before'
    parent=d['target'] if inside else d['parent']
    structural=(d['branch'] if inside else parent is not None)
    partition=inside or d['source_partition']==d['target_partition']
    permission=d['writable'] and (d['copy_allowed'] if d['effect']=='copy' else d['move_allowed'])
    allowed=not selfdrop and structural and partition and permission
    position=d['child_count']+1 if inside else d['target_index']+1+(d['placement']=='after')
    level=d['target_level']+1 if inside else d['target_level']
    effect=d['effect'] if allowed else 'none'
    return [allowed,parent,position,level,effect]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 't', 5, 3, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 'p', 3, 2, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 'p', 2, 2, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 'c', 5, 3, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 't', 5, 3, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 'p', 3, 2, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, None, 2, 2, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 't', 5, 3, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 't', 5, 3, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 'p', 3, 2, 'none'])], 2: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 't', 6, 4, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 'p', 4, 3, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 'p', 3, 3, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 'c', 6, 4, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 't', 6, 4, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 'p', 4, 3, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, None, 3, 3, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 't', 6, 4, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 't', 6, 4, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 'p', 4, 3, 'none'])], 3: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 't', 7, 5, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 'p', 5, 4, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 'p', 4, 4, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 'c', 7, 5, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 't', 7, 5, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 'p', 5, 4, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, None, 4, 4, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 't', 7, 5, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 't', 7, 5, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 'p', 5, 4, 'none'])], 4: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 't', 8, 6, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 'p', 6, 5, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 'p', 5, 5, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 'c', 8, 6, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 't', 8, 6, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 'p', 6, 5, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, None, 5, 5, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 't', 8, 6, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 't', 8, 6, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 'p', 6, 5, 'none'])], 5: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 't', 9, 7, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 'p', 7, 6, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 'p', 6, 6, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 'c', 9, 7, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 't', 9, 7, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 'p', 7, 6, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, None, 6, 6, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 't', 9, 7, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 't', 9, 7, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 'p', 7, 6, 'none'])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(d):
    selfdrop=d['target'] in d['closure']
    inside=d['placement']=='after'
    parent=d['target'] if inside else d['parent']
    structural=(d['branch'] if inside else parent is not None)
    partition=inside or d['source_partition']==d['target_partition']
    permission=d['writable'] and (d['copy_allowed'] if d['effect']=='copy' else d['move_allowed'])
    allowed=not selfdrop and structural and partition and permission
    position=d['child_count']+1 if inside else d['target_index']+1+(d['placement']=='after')
    level=d['target_level']+1 if inside else d['target_level']
    effect=d['effect'] if allowed else 'none'
    return [allowed,parent,position,level,effect]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 't', 5, 3, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 'p', 3, 2, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 'p', 2, 2, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 'c', 5, 3, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 't', 5, 3, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [True, 'p', 3, 2, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, None, 2, 2, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 't', 5, 3, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 't', 5, 3, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 4, 'target_index': 1, 'target_level': 2}, [False, 'p', 3, 2, 'none'])], 2: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 't', 6, 4, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 'p', 4, 3, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 'p', 3, 3, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 'c', 6, 4, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 't', 6, 4, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [True, 'p', 4, 3, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, None, 3, 3, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 't', 6, 4, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 't', 6, 4, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 5, 'target_index': 2, 'target_level': 3}, [False, 'p', 4, 3, 'none'])], 3: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 't', 7, 5, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 'p', 5, 4, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 'p', 4, 4, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 'c', 7, 5, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 't', 7, 5, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [True, 'p', 5, 4, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, None, 4, 4, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 't', 7, 5, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 't', 7, 5, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 6, 'target_index': 3, 'target_level': 4}, [False, 'p', 5, 4, 'none'])], 4: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 't', 8, 6, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 'p', 6, 5, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 'p', 5, 5, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 'c', 8, 6, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 't', 8, 6, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [True, 'p', 6, 5, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, None, 5, 5, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 't', 8, 6, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 't', 8, 6, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 7, 'target_index': 4, 'target_level': 5}, [False, 'p', 6, 5, 'none'])], 5: [('copy inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 't', 9, 7, 'copy']), ('after sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 'p', 7, 6, 'copy']), ('before sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 'p', 6, 6, 'copy']), ('descendant', {'target': 'c', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 'c', 9, 7, 'none']), ('leaf inside', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 't', 9, 7, 'none']), ('leaf sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': False, 'source_partition': 'A', 'target_partition': 'A', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [True, 'p', 7, 6, 'copy']), ('root sibling', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'before', 'parent': None, 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, None, 6, 6, 'none']), ('forbidden copy', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': False, 'move_allowed': True, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 't', 9, 7, 'none']), ('move denied', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'inside', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'move', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 't', 9, 7, 'none']), ('partition mismatch', {'target': 't', 'source': 's', 'closure': ['s', 'c'], 'placement': 'after', 'parent': 'p', 'branch': True, 'source_partition': 'A', 'target_partition': 'B', 'writable': True, 'copy_allowed': True, 'move_allowed': False, 'effect': 'copy', 'child_count': 8, 'target_index': 5, 'target_level': 6}, [False, 'p', 7, 6, 'none'])]}
for label, data, expected in cases[N]:
    check(label, solve(data), expected)
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:
After placement is confused with nesting produces the wrong hierarchical widget state in a regression fixture.

A drag advertises one legal drop location at a time. Inside requires a writable branch; before/after require a parent and same sibling partition. Self and descendant targets are forbidden. Copy needs copy permission. Descriptor includes announced hierarchy level and one-based insertion position.

split: open-access