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

N = 1
observations = []
def solve(d):
    return {'staged-known':([x for x in d['incoming'] if x['field'] in d['fields']]), 'unresolved-review':([x for x in d['incoming'] if x['field'] not in d['fields']]), 'review-trigger':(d['scope']!=d['import_scope'] or d['version']!=d['import_version']), 'duplicate-policy':(d['incoming']), 'publish-reviewed':(d['confirmed'] and all(x['field'] in d['fields'] for x in d['incoming'])), 'import-replacement':(d['incoming'] if d['replace'] else d['existing']+d['incoming'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': []}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': []}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': []}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': []}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]})], 2: [({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}]}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}]}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': False, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'gone', 'value': 2}]})], 3: [({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': False, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': False, 'import-replacement': []}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': False, 'import-replacement': []}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': False, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'gone', 'value': 2}]})], 4: [({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': False, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'gone', 'value': 2}]})], 5: [({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': False, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'gone', 'value': 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)

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 {'staged-known':([x for x in d['incoming'] if x['field'] in d['fields']]), 'unresolved-review':([x for x in d['incoming'] if x['field'] not in d['fields']]), 'review-trigger':(d['scope']!=d['import_scope'] or d['version']!=d['import_version']), 'duplicate-policy':(list({x['field']:x for x in d['incoming']}.values())), 'publish-reviewed':(d['confirmed'] and all(x['field'] in d['fields'] for x in d['incoming'])), 'import-replacement':(d['incoming'] if d['replace'] else d['existing']+d['incoming'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': []}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': []}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': []}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': []}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]})], 2: [({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}]}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}]}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': False, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'gone', 'value': 2}]})], 3: [({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': False, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': False, 'import-replacement': []}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': False, 'import-replacement': []}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': False, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'gone', 'value': 2}]})], 4: [({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': False, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'gone', 'value': 2}]})], 5: [({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': False, 'replace': False, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': False, 'import-replacement': [{'field': 'old', 'value': 3}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': True, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': False, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'unresolved-review': [], 'review-trigger': True, 'duplicate-policy': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}], 'publish-reviewed': True, 'import-replacement': [{'field': 'a', 'value': 0}, {'field': 'a', 'value': 0}, {'field': 'a', 'value': 1}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 1, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': False, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 's', 'version': 1, 'import_version': 2, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 1, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'gone', 'value': 2}]}), ({'incoming': [{'field': 'gone', 'value': 2}], 'fields': ['a'], 'scope': 's', 'import_scope': 'x', 'version': 1, 'import_version': 2, 'deduplicate': False, 'confirmed': True, 'replace': True, 'existing': [{'field': 'old', 'value': 3}]}, {'staged-known': [], 'unresolved-review': [{'field': 'gone', 'value': 2}], 'review-trigger': True, 'duplicate-policy': [{'field': 'gone', 'value': 2}], 'publish-reviewed': False, 'import-replacement': [{'field': 'gone', 'value': 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:
Import deduplication uses full criterion identity and honors the chosen policy is violated by the widget projection.

Importing filter configurations stages known and unresolved constraints, applies an explicit duplicate policy, and requires review when scope or version differs. This example checks: Import deduplication uses full criterion identity and honors the chosen policy.

split: open-access