Skip to content

“Most deadly errors arise from obsolete assumptions.”

Frank Herbert, Children of Dune

Dex Semantics

Let your agent build analytics with 25% fewer errors.

ADE-bench · Sonnet 5.5 · 20 → 15 failures

Thanks to data that explains itself to your coding agent.

The imperial accounts / 01

The Emperor wants his spice report.

Let your agent build your analytics.

You → your coding agent

“Build analytics for spice production and revenue on Arrakis.”

Build the models & record the meaning

Production
Spice extracted
Spice sold
Spice shipped
Revenue
Sold × agreed price

The imperial accounts / 02

The report says spice production doubled overnight.

The report changed overnight (but the desert didn’t)

100 tReport: 200 tReality: still 100 tYesterdayThis morning

The imperial accounts / 03

The join broke silently!

Same shipment, but the new API sends two rows instead of one.

S01+S01

Revenue: 140k → 280k credits.

My Duke, those extra 100 tonnes exist only in the report.

The imperial accounts / 04

Dex embeds semantic meaning explicitly.

Declare the rules → Check the results → Keep the context

The declaration lives with your models

One row per shipment.

  • Production counts harvests.
  • Revenue uses the agreed price.

Stored as code and read next session.

Dex checks the built data

S01 and S02: expected 1 row, found 2.

Duplicate shipments flagged.

The imperial accounts / 05

Without Dex: 200 t

With Dex: 100 t

Proposed fix: tally the lines first, then count harvests separately.

01 / 05

The meaning must flow.

  1. Tests

  2. Semantic models

    dbt Semantic Layer logoApache Ossie logoSLayer logoCube logoSnowflake Semantic Views logoDatabricks Metric Views logo
  3. Next agent session

Illustrated workflow · synthetic Arrakis data

SQL that runs and is wrong.

Your coding agent can write SQL. What it cannot see is what the SQL is supposed to mean: what one row is, which rows belong, how a number adds up.

When that meaning lives only in someone's head, or in the conversation that wrote the model, the next schema change breaks it silently. The query still runs. The numbers are just wrong.

The failure that matters with agents is not SQL that breaks. It is SQL that runs and is wrong.

Three steps, kept as code.

Every model your agent creates or changes carries a declaration. Dex checks the built data against it, reads it back in the next session, and turns it into the semantic layer you already use.

1

Declare the rules

The declaration lives with your models.

It states what one row is, which rows are in, what each column is, and the decisions the model rests on. Dex drafts what it measured: the grain a key proves, foreign keys from verified joins, running totals, unit shapes. The intent is yours: a description, a population, or an assumption is never invented, only asked for.

Evidence tiers: request, contract, precedent, data, default. An ambiguous choice does not stop the agent: it decides on the best evidence, records the choice, and every decision comes back for review.

What a declaration states, and where Dex writes it
FieldWhat it statesWritten as
grainWhat one row isunique + not_null tests (single column)
populationWhich rows belong, and the parent they come fromconfig.meta.dex
role · unit · aggregationWhat each column is and how it adds upconfig.meta.dex
additivityWhether a measure can be summed across timeconfig.meta.dex
null_ruleWhether a column may be emptya not_null test (never)
referencesThe key a foreign key points ata relationships test
assumptionsEach decision, with its evidence tierconfig.meta.dex
2

Check the results

A green build says dbt ran. It does not say the rows are right.

transform build --verify and maintain verify hold each declaration to the relation that was actually built, with aggregate-only statements. No row leaves the warehouse.

A change to an existing model is read against its declaration before it is applied: a removed filter, a dropped grain column, or a SUM of a semi-additive column is named on the plan.

What Dex reports when the built data disagrees with the declaration
DeclaredFinding
graingrain_broken, with the duplicate count
population.filterspopulation_contradicted, with the rows that should not be there
population.parentparent_population_missing · parent_population_unexpected
unit: fraction or percentunit_out_of_range, with the observed range
additivity: additive on a running totaladditivity_contradicted
3

Keep the context

The declaration outlives the conversation that wrote it.

Tests
The grain, NULL rule and foreign keys render as dbt tests, which every build runs.
Next agent session
explore profile and explore map read each declaration back from the YAML on every run, never from a cache. A new session starts from the rule the project records, not one remembered from a chat.
Drift
maintain snapshot fingerprints every declaration, and maintain semantic reports a changed population, grain, unit or aggregation as drift, even when the SQL did not change.
Semantic models
A declared mart gets the semantic definition its declaration already states, in whichever layer the repository reads.

Three rules hold for every layer.

Rule 1

Metrics are never derived.

A measure is what a column holds. A metric is a business definition, and it stays yours.

Rule 2

Nothing is guessed or renamed.

A field a layer cannot carry is named under not_carried, with why.

Rule 3

A population is metadata, never a filter.

The mart's SQL already enforces it. A second copy in the layer would drift the day the two disagree.

One declaration, every semantic layer.

A declared mart derives a semantic model for the layer your repository reads. Snowflake Semantic Views and Databricks Metric Views are written as files in the repository; Dex deploys nothing to either platform.

LayerWhat a declared mart gets
dbt MetricFlowA semantic model: the grain as the primary entity, foreign keys as entities, dimensions, and measures with their aggregation
SLayerA model file: primary_key, many_to_one joins and saved measures
CubeA model file: primary_key, dimensions, measures and joins
Apache OssieA dataset: fields, primary_key, dataset metrics and relationships
Databricks Metric ViewsA Metric View: fields, measures, formats from the unit, and joins
Snowflake Semantic ViewsA logical table: primary_key, dimensions, facts, metrics and relationships

Already have a dbt project?

Models written before declarations existed have none, and Dex never adds them unasked. transform declare proposes, in one capped plan, the measured facts each selected model does not yet state, each with its evidence. It never overwrites a fact the YAML already states, and it reads only the repository and the .dex/ cache, so it is free on every connector.

dex: your dbt project
  1. # propose grain, keys, foreign keys and running totals

    dex transform declare fct_orders dim_customers

  2. # write the reviewed diff

    dex transform apply <plan-id>

  3. # run again for the next batch

    dex transform declare fct_orders dim_customers

ADE-bench · dbt Labs · 75 tasks

25% fewer failed tasks.

With Claude Sonnet 5.5, Dex failed 15 of 75 ADE-bench tasks, against 20 for the same model without Dex: 60 solved against 55.

Dex Semantics: frequently asked questions

Q01What is Dex Semantics?

Dex Semantics keeps each model's meaning with the model, as code. Every dbt model your coding agent creates or changes carries a declaration: what one row is (grain), which rows belong (population), what each column is and how it adds up, and the assumptions behind it. Dex checks the built data against the declaration, reads it back in the next agent session, and derives the semantic model for the layer your repository uses.

Q02Do I have to write declarations by hand?

No. Every plan carries what Dex drafted from what it measured (the grain a key proves, foreign keys from verified joins, running totals, unit shapes), what is already declared, and what is still missing. Measured facts are drafted with their evidence. Intent, such as the description, the population and the assumptions, is never invented: Dex asks for it. On an existing project, dex transform declare proposes the missing facts for the models you select.

Q03Where does a declaration live?

In the model's existing dbt YAML entry, written as a reviewable diff. A single-column grain becomes unique and not_null tests, null_rule: never becomes a not_null test, a foreign key with references becomes a relationships test, and everything else goes under config.meta.dex on the model or the column.

Q04Does checking a declaration read my rows?

No. transform build --verify and maintain verify check the built relation with aggregate-only statements, so no row leaves the warehouse. Findings come back as counts: duplicate keys, rows the population excludes, values outside a declared unit's range.

Q05Which semantic layers does Dex Semantics write?

A declared mart derives a semantic model for dbt MetricFlow, SLayer, Cube, Apache Ossie, Databricks Metric Views or Snowflake Semantic Views, whichever semantic.vendor your repository reads. Metrics are never derived, nothing is guessed or renamed, and a population is carried as metadata, never as a filter. Snowflake Semantic Views and Databricks Metric Views are written as files in the repository; Dex deploys nothing to either platform.

Q06Where does the 25% figure come from?

From the 5 November 2026 ADE-bench run: with Claude Sonnet 5.5, Dex failed 15 of dbt Labs' 75 tasks and the same model without Dex failed 20. That is 25% fewer failed tasks: 60 solved against 55.

Install

Let your agent build your analytics.

Dex Semantics is part of Dex: free and open source under Apache 2.0.

npx skills add exmergo/dex

Codex, Gemini CLI, Cursor, and others, via AGENTS.md.