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

N = 1
observations = []
def solve(d):
    return {'owned-prefix':([k for k in d['keys'] if 'f.' in k]), 'preserve-route':([k for k in d['keys'] if not k.startswith('f.')]), 'multi-serialize':([(d['field'],x) for x in d['values']]), 'literal-comma':(list(d['values'])), 'empty-scalar':([(d['field'],d['text'])] if d['present'] else []), 'scope-key':(d['scope']+'.'+d['field'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'})], 2: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'})], 3: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': '', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.status'})], 4: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.status'})], 5: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'})]}
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 {'owned-prefix':([k for k in d['keys'] if k.startswith('f')]), 'preserve-route':([k for k in d['keys'] if not k.startswith('f.')]), 'multi-serialize':([(d['field'],x) for x in d['values']]), 'literal-comma':(list(d['values'])), 'empty-scalar':([(d['field'],d['text'])] if d['present'] else []), 'scope-key':(d['scope']+'.'+d['field'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'})], 2: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'})], 3: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': '', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.status'})], 4: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.status'})], 5: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'})]}
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:
Filter ownership uses the exact namespaced prefix is violated by the widget projection.

A filter widget owns query keys with the exact f. prefix; it must preserve route parameters and distinguish repeated values from comma-containing literals. This example checks: Filter ownership uses the exact namespaced prefix.

split: open-access


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

N = 1
observations = []
def solve(d):
    return {'owned-prefix':([k for k in d['keys'] if k.startswith('f.')]), 'preserve-route':([]), 'multi-serialize':([(d['field'],x) for x in d['values']]), 'literal-comma':(list(d['values'])), 'empty-scalar':([(d['field'],d['text'])] if d['present'] else []), 'scope-key':(d['scope']+'.'+d['field'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'})], 2: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'})], 3: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': '', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.status'})], 4: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.status'})], 5: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'})]}
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 {'owned-prefix':([k for k in d['keys'] if k.startswith('f.')]), 'preserve-route':([k for k in d['keys'] if not k.startswith('f')]), 'multi-serialize':([(d['field'],x) for x in d['values']]), 'literal-comma':(list(d['values'])), 'empty-scalar':([(d['field'],d['text'])] if d['present'] else []), 'scope-key':(d['scope']+'.'+d['field'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'})], 2: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'})], 3: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': '', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.status'})], 4: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.status'})], 5: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'})]}
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:
URL filter reset preserves every nonowned route parameter is violated by the widget projection.

A filter widget owns query keys with the exact f. prefix; it must preserve route parameters and distinguish repeated values from comma-containing literals. This example checks: URL filter reset preserves every nonowned route parameter.

split: open-access


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

N = 1
observations = []
def solve(d):
    return {'owned-prefix':([k for k in d['keys'] if k.startswith('f.')]), 'preserve-route':([k for k in d['keys'] if not k.startswith('f.')]), 'multi-serialize':([(d['field'],','.join(d['values']))]), 'literal-comma':(list(d['values'])), 'empty-scalar':([(d['field'],d['text'])] if d['present'] else []), 'scope-key':(d['scope']+'.'+d['field'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'})], 2: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'})], 3: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.status'})], 4: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.status'})], 5: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'})]}
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 {'owned-prefix':([k for k in d['keys'] if k.startswith('f.')]), 'preserve-route':([k for k in d['keys'] if not k.startswith('f.')]), 'multi-serialize':([(d['field'],d['values'][0])] if d['values'] else []), 'literal-comma':(list(d['values'])), 'empty-scalar':([(d['field'],d['text'])] if d['present'] else []), 'scope-key':(d['scope']+'.'+d['field'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'right.tag'})], 2: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', 'x')], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', 'x')], 'scope-key': 'left.status'})], 3: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'right.status'})], 4: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [], 'scope-key': 'left.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [], 'scope-key': 'left.status'})], 5: [({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'tag', 'values': [], 'text': 'x', 'present': False, 'scope': 'left'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [], 'scope-key': 'left.tag'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': 'x', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', 'x')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f.color', 'ref.x', 'foo', 'q'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.color'], 'preserve-route': ['ref.x', 'foo', 'q'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'tag', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('tag', 'a,b'), ('tag', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('tag', '')], 'scope-key': 'right.tag'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': [], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [], 'literal-comma': [], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a')], 'literal-comma': ['a'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'}), ({'keys': ['f', 'f.x', 'xf.y'], 'field': 'status', 'values': ['a,b', 'c'], 'text': '', 'present': True, 'scope': 'right'}, {'owned-prefix': ['f.x'], 'preserve-route': ['f', 'xf.y'], 'multi-serialize': [('status', 'a,b'), ('status', 'c')], 'literal-comma': ['a,b', 'c'], 'empty-scalar': [('status', '')], 'scope-key': 'right.status'})]}
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:
Repeated selected values serialize as repeated query pairs is violated by the widget projection.

A filter widget owns query keys with the exact f. prefix; it must preserve route parameters and distinguish repeated values from comma-containing literals. This example checks: Repeated selected values serialize as repeated query pairs.

split: open-access