
The problem
Rules are trusted because they are explicit, and then nobody checks them. A rule written when a vendor always coded to one account keeps firing after the vendor's mix changes, and the errors look like rule output, so nobody questions them.
A rule deserves the same scrutiny as a prediction: how often does it fire, and how often is it right?
How it works
The rules are mined from the tenant's own data with _relate, and only the ones a person has promoted route invoices. Each promoted rule is then replayed over a sample of the tenant's invoices: where its condition matches, the rule's value is compared with the value that was actually posted. The result per rule is its match count, its disagreements, and its precision, next to who promoted it and when.
A rule whose precision drops is a candidate for review, the same way a prediction below its confidence threshold goes to a human. Demote takes it out of routing and records the event, so the audit trail keeps both the promotion and the demotion.
For the full architecture, see the technology overview. For the broader narrative across multiple use cases, read The Predictive Application. For the whole picture, see predictive accounting.
See it live
This use case runs in the 🧾 Accounting demo today. Click through to the live application and inspect the queries that produce the result.
Build it with Claude Code
Paste this prompt into Claude Code, or another coding agent, in your own codebase. It runs Aito locally from the Docker image, reads the API docs written for agents, and follows a working reference implementation.
Add rule precision replay to this codebase using Aito, a predictive database. The feature: replay each of our automation rules against our posted records: how many it matches, how often it disagrees with the posted value, and its precision. 1. Run Aito locally: `docker pull ghcr.io/aitohq/aito`, then follow https://aito.ai/docker/ to start it with your own API keys (keep them in the environment, never in code). 2. Read https://aito.ai/docs/api/llms.txt for the v2 query shapes before writing any query. 3. Read the use-case guide: https://aito.ai/use-cases/rule-precision-replay/ 4. Use this reference implementation as the pattern (schema, data load and queries): https://github.com/AitoDotAI/aito-accounting-demo/blob/main/src/quality_service.py and https://github.com/AitoDotAI/aito-accounting-demo/blob/main/src/rule_governance.py 5. Find the matching tables in this codebase, design the Aito schema for them (links between tables where we have foreign keys), and load a sample. 6. Check the numbers before building the view: compare a few of them against a direct count over the same rows (SQL or a short script), and report any that differ. 7. In the UI, show the evidence behind each number (the counts, the interval or $why), and leave out patterns with too little data behind them. Ask me before changing anything outside the new feature.



