GaurGaur docs

Cross-contract reconciliation

Confirm three Jaffle contracts agree on revenue for the same period.

Use case

A semantic layer's value collapses if two contracts that read the same source disagree. Three Jaffle contracts (store_performance, sales_tax_remittance, hourly_demand) all sum subtotal_usd from orders_clean. Their pre-tax revenue measures should match exactly for any given period. Reconcile them before shipping a new contract, and as a smoke test after any model change.

The three measures

ContractPre-tax revenue measureNotes
store_performancerevenue_usdSliceable by store + time.
sales_tax_remittancetaxable_sales_usdPre-tax sum for tax filings.
hourly_demandrevenue_usdSliceable by store + hour.

sales_tax_remittance.gross_sales_usd is taxable_sales_usd + tax_collected_usd, so it shouldn't match the other two. Reconcile on taxable_sales_usd.

Query

Run the same period through each contract. April 2026:

store_performance
{
  "contract_name": "store_performance",
  "query": {
    "measures": ["revenue_usd"],
    "filters": [
      { "field": "ordered_at", "operator": "gte", "value": "2026-04-01" },
      { "field": "ordered_at", "operator": "lt",  "value": "2026-05-01" }
    ]
  }
}
sales_tax_remittance
{
  "contract_name": "sales_tax_remittance",
  "query": {
    "measures": ["taxable_sales_usd"],
    "filters": [
      { "field": "ordered_at", "operator": "gte", "value": "2026-04-01" },
      { "field": "ordered_at", "operator": "lt",  "value": "2026-05-01" }
    ]
  }
}
hourly_demand
{
  "contract_name": "hourly_demand",
  "query": {
    "measures": ["revenue_usd"],
    "filters": [
      { "field": "ordered_at", "operator": "gte", "value": "2026-04-01" },
      { "field": "ordered_at", "operator": "lt",  "value": "2026-05-01" }
    ]
  }
}

Result

All three should return the same number:

{ "data": { "pagination": { "items": [ { "revenue_usd":      4860420.10 } ] } } }
{ "data": { "pagination": { "items": [ { "taxable_sales_usd": 4860420.10 } ] } } }
{ "data": { "pagination": { "items": [ { "revenue_usd":      4860420.10 } ] } } }

If they don't, stop. Don't trust anything else in the workspace until you find the divergence.

Common reasons reconciliation fails

  • Mixing pre-tax and post-tax. subtotal_usd is pre-tax; order_total_usd is post-tax. A contract that sums the wrong one diverges by exactly the tax amount.
  • Inclusive vs. exclusive date bounds. Use gte + lt for the range (April = [April 1, May 1)). Mixing gte + lte double-counts boundary days.
  • Stale model. If a model was changed but a downstream contract wasn't rebuilt, the contract still sees the old shape.

Notes

Run this as part of CI: three queries against a known-good period; fail the build if they don't match a saved baseline.

Source code

All three contracts ship in the sample dataset: contracts/store_performance.json, contracts/sales_tax_remittance.json, contracts/hourly_demand.json.

On this page