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

N = 1
observations = []
def solve(d):
    return {'merge-order':(d['old']+d['page']), 'load-more':(d['cursor'] is not None and not d['loading']), 'off-page':([x for x in d['selected'] if x not in d['old']+d['page']]), 'end-marker':(d['cursor'] is None), 'replace-query':(list(d['page']) if d['changed'] else list(dict.fromkeys(d['old']+d['page']))), 'visible-total':(len(set(d['old']+d['page'])))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2})], 2: [({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3})], 3: [({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': [], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3})], 4: [({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3})], 5: [({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3})]}
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 {'merge-order':(sorted(set(d['old']+d['page']))), 'load-more':(d['cursor'] is not None and not d['loading']), 'off-page':([x for x in d['selected'] if x not in d['old']+d['page']]), 'end-marker':(d['cursor'] is None), 'replace-query':(list(d['page']) if d['changed'] else list(dict.fromkeys(d['old']+d['page']))), 'visible-total':(len(set(d['old']+d['page'])))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2})], 2: [({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3})], 3: [({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': [], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3})], 4: [({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3})], 5: [({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3})]}
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:
Facet pages deduplicate by identity while retaining first-seen order is violated by the widget projection.

A paged facet picker merges option identities, respects continuation state, and keeps selected off-page options visible in a dedicated selection summary. This example checks: Facet pages deduplicate by identity while retaining first-seen order.

split: open-access


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

N = 1
observations = []
def solve(d):
    return {'merge-order':(list(dict.fromkeys(d['old']+d['page']))), 'load-more':(bool(d['cursor']) and not d['loading']), 'off-page':([x for x in d['selected'] if x not in d['old']+d['page']]), 'end-marker':(d['cursor'] is None), 'replace-query':(list(d['page']) if d['changed'] else list(dict.fromkeys(d['old']+d['page']))), 'visible-total':(len(set(d['old']+d['page'])))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'old': [], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': [], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2})], 2: [({'old': [], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': [], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3})], 3: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': [], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': [], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3})], 4: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': [], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3})], 5: [({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3})]}
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 {'merge-order':(list(dict.fromkeys(d['old']+d['page']))), 'load-more':(d['cursor'] is not None), 'off-page':([x for x in d['selected'] if x not in d['old']+d['page']]), 'end-marker':(d['cursor'] is None), 'replace-query':(list(d['page']) if d['changed'] else list(dict.fromkeys(d['old']+d['page']))), 'visible-total':(len(set(d['old']+d['page'])))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'old': [], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': [], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2})], 2: [({'old': [], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': [], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3})], 3: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': [], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': [], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3})], 4: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': [], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3})], 5: [({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A valid empty continuation cursor still permits the next facet page is violated by the widget projection.

A paged facet picker merges option identities, respects continuation state, and keeps selected off-page options visible in a dedicated selection summary. This example checks: A valid empty continuation cursor still permits the next facet page.

split: open-access


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

N = 1
observations = []
def solve(d):
    return {'merge-order':(list(dict.fromkeys(d['old']+d['page']))), 'load-more':(d['cursor'] is not None and not d['loading']), 'off-page':([]), 'end-marker':(d['cursor'] is None), 'replace-query':(list(d['page']) if d['changed'] else list(dict.fromkeys(d['old']+d['page']))), 'visible-total':(len(set(d['old']+d['page'])))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2})], 2: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2})], 3: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': [], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3})], 4: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3})], 5: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': [], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3})]}
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 {'merge-order':(list(dict.fromkeys(d['old']+d['page']))), 'load-more':(d['cursor'] is not None and not d['loading']), 'off-page':(list(d['selected'])), 'end-marker':(d['cursor'] is None), 'replace-query':(list(d['page']) if d['changed'] else list(dict.fromkeys(d['old']+d['page']))), 'visible-total':(len(set(d['old']+d['page'])))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2})], 2: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': True, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2})], 3: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': False}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': [], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3})], 4: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': [], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': [], 'visible-total': 0}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['a', 'c'], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': None, 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': [], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': 'next', 'loading': False, 'changed': False}, {'merge-order': ['b', 'a', 'c'], 'load-more': True, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['b', 'a', 'c'], 'visible-total': 3})], 5: [({'old': [], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': False, 'changed': False}, {'merge-order': [], 'load-more': True, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': [], 'visible-total': 0}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': [], 'page': ['a', 'c'], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': [], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['a', 'c'], 'load-more': False, 'off-page': ['z', 'b'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': [], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': [], 'visible-total': 2}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': None, 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': True, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': [], 'cursor': 'next', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': [], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3}), ({'old': ['b', 'a'], 'page': ['a', 'c'], 'selected': ['z', 'b'], 'cursor': '', 'loading': True, 'changed': True}, {'merge-order': ['b', 'a', 'c'], 'load-more': False, 'off-page': ['z'], 'end-marker': False, 'replace-query': ['a', 'c'], 'visible-total': 3})]}
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:
Selected values outside loaded pages remain summarized is violated by the widget projection.

A paged facet picker merges option identities, respects continuation state, and keeps selected off-page options visible in a dedicated selection summary. This example checks: Selected values outside loaded pages remain summarized.

split: open-access