"""Invented pair-level contract exercise. No CRM calls or customer records."""
import json
from collections import Counter

# Each pair is independent: incoming record, existing record, expected action.
cases = [
    ('D01', 'same external ID', 'update', 'update'),
    ('D02', 'same normalized email, different ID', 'block', 'block'),
    ('D03', 'same name, different email', 'create', 'block'),
    ('D04', 'two blank emails, different people', 'create', 'create'),
    ('D05', 'same email with outer spaces', 'block', 'create'),
    ('D06', 'shared switchboard, different people', 'create', 'create'),
    ('D07', 'two existing matches for one source key', 'review', 'review'),
    ('D08', 'retry with saved destination ID', 'update', 'update'),
]
results = [dict(case=i, scenario=s, expected=e, candidate=a, matches=e == a)
           for i, s, e, a in cases]
output = dict(kind='synthetic decision contract, not a vendor benchmark',
              cases=results,
              expected_counts=dict(Counter(x[2] for x in cases)),
              candidate_counts=dict(Counter(x[3] for x in cases)),
              mismatches=[r['case'] for r in results if not r['matches']])
assert output['expected_counts'] == output['candidate_counts']
assert output['mismatches'] == ['D03', 'D05']
print(json.dumps(output, indent=2))
