# Category rules · how a line gets its ledger

Three passes, in this order. A line stops at the first pass that decides it.

1. **Masters.** Narration contains a name from `masters.csv` → that party's ledger. Direction (debit or credit) decides debtor or creditor.
2. **Rules.** Narration matches a pattern in `category-rules.csv` → that category and ledger, with the status the rule sets (auto, review, ask).
3. **Model.** Everything left goes to the AI model on your own API key with the narration, amount, direction and the ledger list. It returns a suggested ledger and a confidence. At or above the threshold (0.90 by default) it is marked auto; below it, review. It never posts.

## Statuses

| Status | Meaning | Who acts |
|---|---|---|
| auto | Ledger decided by masters, rules or a confident suggestion | Nobody until the monthly approval |
| review | Ledger suggested; needs a firm accountant's confirmation | Review owner |
| ask | Needs a fact only the client has | Client, on WhatsApp; firm books the answer |

## Growing the rules

Every answered exception is a candidate rule. Add the pattern, the ledger and the status. After three months most clients settle at 25 to 40 rules and under ten questions a month.

## Rules that must stay on ask

Cheque returns, cash deposits above the threshold, unidentified receipts, owner or director narrations, duplicate invoice numbers.
