"""Invented reconciliation fixture; executes no vendor API calls. Python 3."""
import copy
import json
from collections import Counter

expected = [
    dict(id='N01', author='U1', time='2026-10-01T09:00:00Z', text='Budget approved.', links=['deal:D1']),
    dict(id='N02', author='U2', time='2026-10-02T09:00:00Z', text='Call finance.\nThen send contract.', links=['deal:D2']),
    dict(id='N03', author='U3', time='2026-10-03T09:00:00Z', text='Renewal agreed.', links=['company:C1', 'deal:D3']),
    dict(id='N04', author='U1', time='2026-10-04T09:00:00Z', text='Do not extend credit.', links=['deal:D4']),
    dict(id='N05', author='U2', time='2026-10-05T09:00:00Z', text='Customer asked for a callback.', links=['deal:D5']),
    dict(id='N06', author='U3', time='2026-10-06T09:00:00Z', text='Customer asked for a callback.', links=['deal:D6']),
]
actual = copy.deepcopy(expected)
actual[0]['author'], actual[1]['author'] = actual[1]['author'], actual[0]['author']
actual[1]['text'] = 'Call finance.Then send contract.'
actual[2]['links'] = ['deal:D3']
actual[3]['text'] = 'Do extend credit.'
actual[4]['time'] = '2026-12-01T09:00:00Z'
fields = ['author', 'time', 'text', 'links']
mismatches = {e['id']: [f for f in fields if e[f] != a[f]] for e, a in zip(expected, actual)}
mismatches = {key: value for key, value in mismatches.items() if value}
result = dict(expected_count=len(expected), actual_count=len(actual),
    author_totals_match=Counter(n['author'] for n in expected)==Counter(n['author'] for n in actual),
    mismatched_notes=len(mismatches), mismatches=mismatches,
    valid_identical_text_notes=[n['id'] for n in expected if n['text']=='Customer asked for a callback.'])
assert result['mismatched_notes'] == 5
assert result['author_totals_match']
print(json.dumps(result, indent=2))
