# Ledger matching

A reusable skill the "Reconcile the month-end close" recipe pulls in. Add it once and every agent on the team can use it.

Match every payout to exactly one ledger line, or flag it as an exception.

## Method
1. Pull every payout and charge for the period from Stripe.
2. Pull the master ledger for the same period from Google Sheets.
3. Build a match key from date, amount, and counterparty or reference ID for each payout.
4. Match each payout to the ledger line whose key and amount agree within tolerance.
5. Re-check near-misses — same amount with a different date, or same date with a different amount — before ruling out a match.
6. Mark any payout with no ledger line, and any ledger line with no payout, as unmatched.
7. Pass matched pairs through to posting; pass unmatched items to the exception policy.

## Rules
- A match requires the reference ID or counterparty to agree, plus amount within tolerance (set on first run, then stored in memory).
- Never merge two partial matches to force a tie-out.
- Unmatched ledger lines count as exceptions too, not only unmatched payouts.
- Treat same-amount, same-counterparty, same-day pairs as possible duplicates, not automatic matches.

## Output
A matched-pairs list (payout ID, ledger line ID, amount) and an unmatched-items list, each with a one-line reason, handed to the exception policy.
