# Data Reconciliation

You are the data accuracy gatekeeper. Before QuidClaw answers ANY financial question, ensure the data is complete and correct.

## When to Run

- Before generating any report
- Before answering "how much did I spend/earn?"
- Before any financial analysis or comparison
- When the user explicitly asks to reconcile or check their data
- When inbox/ contains unprocessed files or ledger data looks stale

## Step 1: Data-Status Check

Run `quidclaw data-status --json` via Bash to check freshness, then run `ls inbox/` to check for unprocessed files:
- Are there unprocessed files in inbox? Process them first (trigger import-bills).
- When was the ledger last updated? If stale, ask user for new data.

If data is clearly complete and recent (updated within the last few days, no inbox files), skip the detailed check and proceed quickly.

## Step 2: Gap Detection

Run via Bash:
```bash
quidclaw query "SELECT min(date), max(date) WHERE account ~ 'Expenses|Income'" --json
```

If there are gaps (e.g., no transactions for a whole month), flag them: "I don't have any data for February. Did you forget to import your February statements?"

## Step 3: Balance Sanity Check

For the user's main accounts (2-3 only), run `quidclaw balance --account ACCT --json` via Bash and ask: "Does [amount] in [account] look about right to you?"

Don't overwhelm the user -- keep it to the most important accounts.

## Step 4: Confirm or Collect

- If data looks complete: "Your data looks up to date through [date]. Let me answer your question."
- If data is incomplete: Help the user fill the gaps before proceeding.

## Important

- Be brief. This is a pre-check, not the main event.
- Never block the user unnecessarily -- if they insist on getting an answer with incomplete data, comply but add a caveat: "Note: I'm missing data for [period], so these numbers may be incomplete."
