For analytics engineers and data leads who want agents to stop reinventing metrics.
Updated
A business glossary agents can query defines each metric once: its name, what it measures, the entity it is counted at (the grain), how it is calculated, its default time field and groupings, and its unit. The Brain stores each as a metric record, so an agent asks for "Net revenue" and gets one definition instead of inventing a calculation.
Write the definition where your team already works, then let the Brain hold it. For each metric record the name, what it measures, the grain entity, how it is calculated, the default time field and groupings, and the unit. Keep terms and rules separate: a term says what a word means, a rule says what must hold.
## Net revenue
Sum of order totals in dollars for orders with status shipped,
excluding refunded orders. Counted per Order. Default time field:
placed_at. Usually grouped by region. Unit: USD.If you already model metrics in dbt, upload the dbt artifacts (the manifest, plus the catalog and semantic manifest if you have them) so the metrics defined there arrive as metric records. Otherwise put definitions in markdown and sync the folder, then review what ingestion proposes before it merges.
npx -y @brainbox-labs/cli@latest meta ingest dbt --artifacts ./target
npx -y @brainbox-labs/cli@latest sync ./glossary --namespace glossaryThe agent calls recall_domain with kind set to metric. With a name it gets that metric, and without one it lists them. The result carries the grain entity, unit, kind and origin. The built-in compiler covers single-grain aggregations; for anything more complex the metric points at the upstream engine instead of re-deriving the calculation.
{ "kind": "metric", "name": "Net revenue" }| Field | What it holds |
|---|---|
| name, description | The business name and what it measures |
| grain entity | The entity each row is counted at, such as Order or Subscription |
| kind | sum, count, count_distinct, avg, min, max, ratio or custom |
| expression | A SQL aggregate (select and optional where), a ratio of two metrics, or a reference to a dbt or Cube metric |
| default time field and group-bys | The usual time bucket and groupings, as fields on the grain entity |
| unit, format | Units, and display as currency, number, percent or duration |
| origin | dbt, cube, metricflow, sql_query_mined or curated |