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

N = 1
observations = []
def solve(d):
    return {'replace-user':(d['saved'] if d['mode']=='replace' else [x for i,x in enumerate(d['current']+d['saved']) if x not in (d['current']+d['saved'])[:i]]), 'enforced-separation':(d['enforced']+d['saved']), 'overlay-provenance':('view' if d['mode']=='replace' else 'mixed'), 'hidden-retention':([x for x in d['current'] if x[0] not in d['visible']] if d['mode']=='overlay' else []), 'field-overlay-policy':([x for x in d['current'] if d['policies'].get(x[0])!='replace']+[x for x in d['saved'] if d['policies'].get(x[0])!='keep']), 'effective-view-count':(len(d['saved']))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2})], 2: [({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2})], 3: [({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2})], 4: [({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2})], 5: [({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2})]}
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 {'replace-user':(d['saved'] if d['mode']=='replace' else [x for i,x in enumerate(d['current']+d['saved']) if x not in (d['current']+d['saved'])[:i]]), 'enforced-separation':(d['enforced']+d['saved']), 'overlay-provenance':('view' if d['mode']=='replace' else 'mixed'), 'hidden-retention':([x for x in d['current'] if x[0] not in d['visible']] if d['mode']=='overlay' else []), 'field-overlay-policy':([x for x in d['current'] if d['policies'].get(x[0])!='replace']+[x for x in d['saved'] if d['policies'].get(x[0])!='keep']), 'effective-view-count':(len(set(x[0] for x in d['saved']+d['enforced'])))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2})], 2: [({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2})], 3: [({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2})], 4: [({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2})], 5: [({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['b', 'x']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'overlay', 'visible': ['a'], 'scope': 'ss', 'view_scope': 's', 'policies': {'a': 'keep'}}, {'replace-user': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'enforced-separation': [['a', 'required'], ['b', 'x']], 'overlay-provenance': 'mixed', 'hidden-retention': [['hidden', 'z']], 'field-overlay-policy': [['a', 'old'], ['hidden', 'z'], ['b', 'x']], 'effective-view-count': 2}), ({'saved': [['a', 'new']], 'current': [['a', 'old'], ['hidden', 'z']], 'enforced': [['a', 'required']], 'mode': 'replace', 'visible': ['a'], 'scope': 's', 'view_scope': 's', 'policies': {'a': 'replace'}}, {'replace-user': [['a', 'new']], 'enforced-separation': [['a', 'required'], ['a', 'new']], 'overlay-provenance': 'view', 'hidden-retention': [], 'field-overlay-policy': [['hidden', 'z'], ['a', 'new']], 'effective-view-count': 2})]}
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:
Effective view summaries count enforced and user constraints separately is violated by the widget projection.

Applying a saved view may replace or overlay editable filters, but it never replaces enforced scope and retains hidden selected criteria unless replace mode explicitly clears them. This example checks: Effective view summaries count enforced and user constraints separately.

split: open-access


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

N = 1
observations = []
def solve(d):
    return {'normalize-drag':([d['start'],d['end']]), 'bucket-intersection':([i for i,(a,b) in enumerate(d['bins']) if a<max(d['start'],d['end']) and b>min(d['start'],d['end'])] if d['start']!=d['end'] else []), 'click-no-range':(d['start']==d['end']), 'brush-domain-start':(max(d['minimum'],min(d['start'],d['end']))), 'brush-domain-end':(min(d['maximum'],max(d['start'],d['end']))), 'brush-publish':(d['released'] and d['start']!=d['end'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'start': 1, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': False}), ({'start': -1, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [-1, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': True}), ({'start': -1, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [-1, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 0, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': False}), ({'start': 0, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 2], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 2, 'brush-publish': True}), ({'start': 1, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [1, 1], 'bucket-intersection': [], 'click-no-range': True, 'brush-domain-start': 1, 'brush-domain-end': 1, 'brush-publish': False}), ({'start': 1, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [1, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 3, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 3, 'brush-publish': True}), ({'start': 3, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [2, 3], 'bucket-intersection': [1], 'click-no-range': False, 'brush-domain-start': 2, 'brush-domain-end': 3, 'brush-publish': False}), ({'start': 3, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [3, 5], 'bucket-intersection': [1, 2], 'click-no-range': False, 'brush-domain-start': 3, 'brush-domain-end': 5, 'brush-publish': True})], 2: [({'start': 1, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': True}), ({'start': -1, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [-1, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 0, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 1, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [1, 2], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 2, 'brush-publish': False}), ({'start': 1, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [1, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 3, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [1, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 3, 'brush-publish': False}), ({'start': 3, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [2, 3], 'bucket-intersection': [1], 'click-no-range': False, 'brush-domain-start': 2, 'brush-domain-end': 3, 'brush-publish': True}), ({'start': 6, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 6], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 6, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [1, 6], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 6, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [5, 6], 'bucket-intersection': [2], 'click-no-range': False, 'brush-domain-start': 5, 'brush-domain-end': 5, 'brush-publish': False})], 3: [({'start': 3, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 3, 'brush-publish': False}), ({'start': 1, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': True}), ({'start': 1, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [1, 2], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 2, 'brush-publish': True}), ({'start': 3, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [1, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 3, 'brush-publish': True}), ({'start': 3, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [3, 5], 'bucket-intersection': [1, 2], 'click-no-range': False, 'brush-domain-start': 3, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 6, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 6], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 6, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [2, 6], 'bucket-intersection': [1, 2], 'click-no-range': False, 'brush-domain-start': 2, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 6, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [5, 6], 'bucket-intersection': [2], 'click-no-range': False, 'brush-domain-start': 5, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': -1, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [-1, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': False}), ({'start': -1, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [-1, 2], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 2, 'brush-publish': True})], 4: [({'start': 3, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 3, 'brush-publish': True}), ({'start': 3, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [1, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 3, 'brush-publish': False}), ({'start': 3, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [2, 3], 'bucket-intersection': [1], 'click-no-range': False, 'brush-domain-start': 2, 'brush-domain-end': 3, 'brush-publish': False}), ({'start': 3, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [3, 5], 'bucket-intersection': [1, 2], 'click-no-range': False, 'brush-domain-start': 3, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 6, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [1, 6], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 6, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [2, 6], 'bucket-intersection': [1, 2], 'click-no-range': False, 'brush-domain-start': 2, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': -1, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [-1, 0], 'bucket-intersection': [], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 0, 'brush-publish': False}), ({'start': -1, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [-1, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': True}), ({'start': -1, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [-1, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 0, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 0], 'bucket-intersection': [], 'click-no-range': True, 'brush-domain-start': 0, 'brush-domain-end': 0, 'brush-publish': False})], 5: [({'start': 3, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [1, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 3, 'brush-publish': False}), ({'start': 3, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [2, 3], 'bucket-intersection': [1], 'click-no-range': False, 'brush-domain-start': 2, 'brush-domain-end': 3, 'brush-publish': True}), ({'start': 6, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [1, 6], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 6, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [5, 6], 'bucket-intersection': [2], 'click-no-range': False, 'brush-domain-start': 5, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': -1, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [-1, 0], 'bucket-intersection': [], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 0, 'brush-publish': True}), ({'start': -1, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [-1, 2], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 2, 'brush-publish': False}), ({'start': -1, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [-1, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 0, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': False}), ({'start': 0, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 2], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 2, 'brush-publish': True}), ({'start': 1, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': False})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(d):
    return {'normalize-drag':([abs(d['start']),abs(d['end'])]), 'bucket-intersection':([i for i,(a,b) in enumerate(d['bins']) if a<max(d['start'],d['end']) and b>min(d['start'],d['end'])] if d['start']!=d['end'] else []), 'click-no-range':(d['start']==d['end']), 'brush-domain-start':(max(d['minimum'],min(d['start'],d['end']))), 'brush-domain-end':(min(d['maximum'],max(d['start'],d['end']))), 'brush-publish':(d['released'] and d['start']!=d['end'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'start': 1, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': False}), ({'start': -1, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [-1, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': True}), ({'start': -1, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [-1, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 0, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': False}), ({'start': 0, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 2], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 2, 'brush-publish': True}), ({'start': 1, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [1, 1], 'bucket-intersection': [], 'click-no-range': True, 'brush-domain-start': 1, 'brush-domain-end': 1, 'brush-publish': False}), ({'start': 1, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [1, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 3, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 3, 'brush-publish': True}), ({'start': 3, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [2, 3], 'bucket-intersection': [1], 'click-no-range': False, 'brush-domain-start': 2, 'brush-domain-end': 3, 'brush-publish': False}), ({'start': 3, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [3, 5], 'bucket-intersection': [1, 2], 'click-no-range': False, 'brush-domain-start': 3, 'brush-domain-end': 5, 'brush-publish': True})], 2: [({'start': 1, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': True}), ({'start': -1, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [-1, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 0, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 1, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [1, 2], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 2, 'brush-publish': False}), ({'start': 1, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [1, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 3, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [1, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 3, 'brush-publish': False}), ({'start': 3, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [2, 3], 'bucket-intersection': [1], 'click-no-range': False, 'brush-domain-start': 2, 'brush-domain-end': 3, 'brush-publish': True}), ({'start': 6, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 6], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 6, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [1, 6], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 6, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [5, 6], 'bucket-intersection': [2], 'click-no-range': False, 'brush-domain-start': 5, 'brush-domain-end': 5, 'brush-publish': False})], 3: [({'start': 3, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 3, 'brush-publish': False}), ({'start': 1, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': True}), ({'start': 1, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [1, 2], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 2, 'brush-publish': True}), ({'start': 3, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [1, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 3, 'brush-publish': True}), ({'start': 3, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [3, 5], 'bucket-intersection': [1, 2], 'click-no-range': False, 'brush-domain-start': 3, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 6, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 6], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 6, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [2, 6], 'bucket-intersection': [1, 2], 'click-no-range': False, 'brush-domain-start': 2, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 6, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [5, 6], 'bucket-intersection': [2], 'click-no-range': False, 'brush-domain-start': 5, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': -1, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [-1, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': False}), ({'start': -1, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [-1, 2], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 2, 'brush-publish': True})], 4: [({'start': 3, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 3, 'brush-publish': True}), ({'start': 3, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [1, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 3, 'brush-publish': False}), ({'start': 3, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [2, 3], 'bucket-intersection': [1], 'click-no-range': False, 'brush-domain-start': 2, 'brush-domain-end': 3, 'brush-publish': False}), ({'start': 3, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [3, 5], 'bucket-intersection': [1, 2], 'click-no-range': False, 'brush-domain-start': 3, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 6, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [1, 6], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 6, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [2, 6], 'bucket-intersection': [1, 2], 'click-no-range': False, 'brush-domain-start': 2, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': -1, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [-1, 0], 'bucket-intersection': [], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 0, 'brush-publish': False}), ({'start': -1, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [-1, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': True}), ({'start': -1, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [-1, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': 0, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 0], 'bucket-intersection': [], 'click-no-range': True, 'brush-domain-start': 0, 'brush-domain-end': 0, 'brush-publish': False})], 5: [({'start': 3, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [1, 3], 'bucket-intersection': [0, 1], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 3, 'brush-publish': False}), ({'start': 3, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [2, 3], 'bucket-intersection': [1], 'click-no-range': False, 'brush-domain-start': 2, 'brush-domain-end': 3, 'brush-publish': True}), ({'start': 6, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [1, 6], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 1, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 6, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [5, 6], 'bucket-intersection': [2], 'click-no-range': False, 'brush-domain-start': 5, 'brush-domain-end': 5, 'brush-publish': False}), ({'start': -1, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [-1, 0], 'bucket-intersection': [], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 0, 'brush-publish': True}), ({'start': -1, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [-1, 2], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 2, 'brush-publish': False}), ({'start': -1, 'end': 5, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [-1, 5], 'bucket-intersection': [0, 1, 2], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 5, 'brush-publish': True}), ({'start': 0, 'end': 1, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': False}), ({'start': 0, 'end': 2, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': True}, {'normalize-drag': [0, 2], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 2, 'brush-publish': True}), ({'start': 1, 'end': 0, 'bins': [[0, 2], [2, 4], [4, 6]], 'minimum': 0, 'maximum': 5, 'released': False}, {'normalize-drag': [0, 1], 'bucket-intersection': [0], 'click-no-range': False, 'brush-domain-start': 0, 'brush-domain-end': 1, 'brush-publish': False})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Reverse histogram drags normalize their endpoint order is violated by the widget projection.

A histogram brush selects intersecting bucket identities over a half-open horizontal interval; clicks without width do not create a range and the final brush converts to domain edges. This example checks: Reverse histogram drags normalize their endpoint order.

split: open-access