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

N = 1
observations = []
def solve(d):
    return {'revision-pending':(d['sent']>d['ack']), 'result-fresh':(d['result']==d['ack']), 'error-scope':(d['error_revision']==d['sent']), 'dirty-count':(abs(len(d['draft'])-len(d['applied']))), 'result-label':('updating' if d['sent']>d['ack'] else str(d['count'])), 'retry-payload':(list(d['draft']) if d['error_revision']==d['sent'] else None)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None})], 2: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']})], 3: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None})], 4: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']})], 5: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None})]}
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 {'revision-pending':(d['sent']>d['ack']), 'result-fresh':(d['result']==d['ack']), 'error-scope':(d['error_revision']==d['sent']), 'dirty-count':(len(set(d['draft'])|set(d['applied']))), 'result-label':('updating' if d['sent']>d['ack'] else str(d['count'])), 'retry-payload':(list(d['draft']) if d['error_revision']==d['sent'] else None)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None})], 2: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']})], 3: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None})], 4: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']})], 5: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None})]}
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:
Pending change counts include both added and removed criteria is violated by the widget projection.

The applied-filter summary distinguishes settled, pending and failed draft updates, and uses the server-acknowledged filter revision for result badges. This example checks: Pending change counts include both added and removed criteria.

split: open-access


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

N = 1
observations = []
def solve(d):
    return {'revision-pending':(d['sent']>d['ack']), 'result-fresh':(d['result']==d['ack']), 'error-scope':(d['error_revision']==d['sent']), 'dirty-count':(len(set(d['draft']) ^ set(d['applied']))), 'result-label':(str(d['count'])), 'retry-payload':(list(d['draft']) if d['error_revision']==d['sent'] else None)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None})], 2: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']})], 3: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']})], 4: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']})], 5: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None})]}
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 {'revision-pending':(d['sent']>d['ack']), 'result-fresh':(d['result']==d['ack']), 'error-scope':(d['error_revision']==d['sent']), 'dirty-count':(len(set(d['draft']) ^ set(d['applied']))), 'result-label':('updating' if d['sent']!=d['result'] else str(d['count'])), 'retry-payload':(list(d['draft']) if d['error_revision']==d['sent'] else None)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None})], 2: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']})], 3: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']})], 4: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']})], 5: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A filter submission masks settled result counts until acknowledged is violated by the widget projection.

The applied-filter summary distinguishes settled, pending and failed draft updates, and uses the server-acknowledged filter revision for result badges. This example checks: A filter submission masks settled result counts until acknowledged.

split: open-access


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

N = 1
observations = []
def solve(d):
    return {'revision-pending':(d['sent']>d['ack']), 'result-fresh':(d['result']==d['ack']), 'error-scope':(d['error_revision']==d['sent']), 'dirty-count':(len(set(d['draft']) ^ set(d['applied']))), 'result-label':('updating' if d['sent']>d['ack'] else str(d['count'])), 'retry-payload':(list(d['applied']) if d['error_revision']==d['sent'] else None)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None})], 2: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']})], 3: [({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None})], 4: [({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']})], 5: [({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None})]}
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 {'revision-pending':(d['sent']>d['ack']), 'result-fresh':(d['result']==d['ack']), 'error-scope':(d['error_revision']==d['sent']), 'dirty-count':(len(set(d['draft']) ^ set(d['applied']))), 'result-label':('updating' if d['sent']>d['ack'] else str(d['count'])), 'retry-payload':(list(d['draft']))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None})], 2: [({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '0', 'retry-payload': ['x']})], 3: [({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': None, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 0, 'result-label': '8', 'retry-payload': ['x']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': None, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': '8', 'retry-payload': None})], 4: [({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '0', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']})], 5: [({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 0}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '0', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 2, 'error_revision': 1, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': False, 'error-scope': False, 'dirty-count': 2, 'result-label': 'updating', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 2, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': True, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 1, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': False, 'dirty-count': 0, 'result-label': '8', 'retry-payload': None}), ({'sent': 2, 'ack': 3, 'result': 2, 'error_revision': 2, 'draft': ['y'], 'applied': ['x'], 'count': 8}, {'revision-pending': False, 'result-fresh': False, 'error-scope': True, 'dirty-count': 2, 'result-label': '8', 'retry-payload': ['y']}), ({'sent': 2, 'ack': 1, 'result': 1, 'error_revision': 1, 'draft': ['x'], 'applied': ['x'], 'count': 8}, {'revision-pending': True, 'result-fresh': True, 'error-scope': False, 'dirty-count': 0, 'result-label': 'updating', 'retry-payload': None})]}
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:
Retry targets the failed current draft and does not retry old errors is violated by the widget projection.

The applied-filter summary distinguishes settled, pending and failed draft updates, and uses the server-acknowledged filter revision for result badges. This example checks: Retry targets the failed current draft and does not retry old errors.

split: open-access