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

N = 1
observations = []
def solve(d):
    return {'cycle-block':(d['target']==d['source']), 'source-membership':(d['criterion'] in d['source_rows']), 'destination-duplicate':(d['criterion'] in d['target_rows'] and d['target']!=d['source']), 'source-removal':([x for x in d['source_rows'] if x!=d['criterion']]), 'destination-insert':(d['target_rows'][:d['index']]+[d['criterion']]+d['target_rows'][d['index']:]), 'flatten-safe':(d['source_mode']==d['target_mode'] and not d['negated'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False})], 2: [({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': True}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False})], 3: [({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': True})], 4: [({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False})], 5: [({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': False, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), 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):
    return {'cycle-block':(d['target'] in d['descendants']), 'source-membership':(d['criterion'] in d['source_rows']), 'destination-duplicate':(d['criterion'] in d['target_rows'] and d['target']!=d['source']), 'source-removal':([x for x in d['source_rows'] if x!=d['criterion']]), 'destination-insert':(d['target_rows'][:d['index']]+[d['criterion']]+d['target_rows'][d['index']:]), 'flatten-safe':(d['source_mode']==d['target_mode'] and not d['negated'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False})], 2: [({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': True}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False})], 3: [({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': True})], 4: [({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False})], 5: [({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': False, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), 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:
Group drops reject both self targets and descendant targets is violated by the widget projection.

A filter-builder drag moves a criterion between explicit group identities, rejects descendant cycles, and retains operator grouping when flattening is unsafe. This example checks: Group drops reject both self targets and descendant targets.

split: open-access


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

N = 1
observations = []
def solve(d):
    return {'cycle-block':(d['target'] in d['descendants'] or d['target']==d['source']), 'source-membership':(True), 'destination-duplicate':(d['criterion'] in d['target_rows'] and d['target']!=d['source']), 'source-removal':([x for x in d['source_rows'] if x!=d['criterion']]), 'destination-insert':(d['target_rows'][:d['index']]+[d['criterion']]+d['target_rows'][d['index']:]), 'flatten-safe':(d['source_mode']==d['target_mode'] and not d['negated'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False})], 2: [({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': True}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False})], 3: [({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': True})], 4: [({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False})], 5: [({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': False, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), 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):
    return {'cycle-block':(d['target'] in d['descendants'] or d['target']==d['source']), 'source-membership':(d['criterion'] in d['target_rows']), 'destination-duplicate':(d['criterion'] in d['target_rows'] and d['target']!=d['source']), 'source-removal':([x for x in d['source_rows'] if x!=d['criterion']]), 'destination-insert':(d['target_rows'][:d['index']]+[d['criterion']]+d['target_rows'][d['index']:]), 'flatten-safe':(d['source_mode']==d['target_mode'] and not d['negated'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False})], 2: [({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': True}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False})], 3: [({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': True})], 4: [({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False})], 5: [({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['x', 'a', 'y'], 'flatten-safe': False}), ({'target': 's', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': True, 'source-membership': True, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 0, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False}), ({'target': 'child', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': ['a'], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': True}, {'cycle-block': True, 'source-membership': False, 'destination-duplicate': True, 'source-removal': ['b'], 'destination-insert': ['a', 'a'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'and', 'negated': False}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': True}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['a', 'b'], 'target_rows': ['x', 'y'], 'index': 0, 'source_mode': 'and', 'target_mode': 'and', 'negated': True}, {'cycle-block': False, 'source-membership': True, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a', 'x', 'y'], 'flatten-safe': False}), ({'target': 'other', 'source': 's', 'descendants': ['child'], 'criterion': 'a', 'source_rows': ['b'], 'target_rows': [], 'index': 1, 'source_mode': 'and', 'target_mode': 'or', 'negated': False}, {'cycle-block': False, 'source-membership': False, 'destination-duplicate': False, 'source-removal': ['b'], 'destination-insert': ['a'], 'flatten-safe': False})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), 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:
A drag must originate from a group containing the criterion is violated by the widget projection.

A filter-builder drag moves a criterion between explicit group identities, rejects descendant cycles, and retains operator grouping when flattening is unsafe. This example checks: A drag must originate from a group containing the criterion.

split: open-access