All projects
Case study · synthetic data Updated: October 2026

AI drafts the report. No number goes out unchecked.

A monthly KPI report where a language model writes the commentary and a checker tests every figure against the data. If a single number cannot be backed, the report is blocked.

PythonLLMpandaspytestKPI reportingRelease gatelaunchdClaude Haiku
IndustryE-commerce
My roleControl design and QA
Volume~47,000 orders
ValidationRelease gate + 22 tests
ScheduleWeekly, Mondays 07:30
Report blocked: five numbers in the commentary are not backed by the data

Context

Language models write good first drafts of a monthly commentary. They also make exactly the mistakes that make finance stop trusting a report: a figure that is close but not right, year-on-year quoted as month-on-month, “grew” where the data fell, a number borrowed from another metric, or an outside figure nobody sourced.

Checking sentence by sentence by hand defeats the point of automating.

Approach

Facts firstThe month's KPIs are computed from raw orders: revenue, orders, average ticket, margin, returns, new customers and CAC, against the previous month and the same month last year.
The model draftsIt receives only those facts and a short instruction. It has nowhere else to take numbers from.
Every number is checkedThat it exists at the rounding the text shows, belongs to the metric the sentence names, to the period it states, and that the verb matches the sign.
Release gateThe report marks every number green or red. If one is red, the job exits with an error and nothing is published.

Test

Two drafts ship with the repository: one correct and one with five typical mistakes planted on purpose. This is the actual output:

kpicheck
$ python run.py --draft examples/draft_ok.md
18 numbers checked, 0 problems -> RELEASED

$ python run.py --draft examples/draft_with_errors.md
13 numbers checked, 5 problems -> BLOCKED
  NOT_FOUND             4,8  | La facturación bajó 4,8% contra agosto ...
  WRONG_DIRECTION      10,6  | Los clientes nuevos crecieron 10,6% contra agosto ...
  WRONG_METRIC          7,9  | La tasa de devolución fue 7,9% ...
  WRONG_PERIOD         30,7  | El CAC subió 30,7% contra agosto.
  NOT_FOUND              30  | ... una inflación cercana al 30% anual.

Result

Output of the test case (synthetic data, errors planted on purpose):

18numbers in the correct draftall verified: released
5typical errors plantedall flagged: blocked
4distinct error typesvalue, metric, period, direction
Limit, stated plainly: the checker proves every number is right. Whether the explanation is the right one is still the analyst's call, which is why the report has a human owner.

Live

The same check now runs by itself every Monday at 07:30 (Berlin) on a synthetic weekly feed. Before the model is asked for a draft, a data check reviews the load; about one week in eight the feed carries a problem planted on purpose (a day loaded twice, a missing day, refunds loaded as sales) and that week is blocked without calling the model.

6weekly runslast refreshed 2026-11-23
3blockedby the data or the number check
21numbers checked in the last runweek 2026-W47: blocked

Every run, with its result, reason and cost: run history. Synthetic data.

Deliverables

  • Reproducible KPI computation from raw data.
  • Number checker for Argentine formatting (1.234,5).
  • HTML report with every figure in green or red.
  • Release gate that blocks publishing, ready for a scheduled job.
Next caseData migration with reconciliation