Full source:
examples/saas-analytics/Schema
Business Vault (8 dimensions, 10 facts) + 4 data marts:Setup
Bundled DuckDB file: no server, no credentials.Quickstart
Unlike the other guides, there’s nocanonic ingest --bootstrap step here: every semantic source, metric, and guardrail already ships provenance: human_curated in contracts/ and semantics/, so there is nothing to bootstrap. (Run canonic ingest --dry-run any time to see it reconcile cleanly against the live saas.duckdb schema with zero diffs.)
Metric catalogue: all 7 binding kinds
Ratio and weighted-avg components must themselves be
single-kind metrics, so a set of small helper metrics (mrr_total, active_accounts, churned_customers, new_customers, won_opportunities, total_opportunities, campaign_spend, discount_value_sum, total_contract_value, nps_net, nps_responses) provide those building blocks. See The semantic compiler for how each kind actually compiles.
Guardrails: all four kinds
revenue-excludes-refunds/revenue-excludes-trials:mandatory_filter(error). Injectsstatus != 'refunded'andis_trial = falseinto everygross_revenuequery.board-reporting-final-only:restrict_source(error). In theboard_reportingcontext, confinesgross_revenueto the finalfct_invoicessource, paired with a finality rule (finality-revenue) that declares the final/provisional realizations and coalescing rule.board-reporting-trusted-only:min_trust(error). In theboard_reportingcontext, blocks the query unless the answer’s trust tier meets the declared floor.ending-mrr-requires-month:required_dimension(warn). Requires groupingending_mrrbysnapshot_month. Unlike the guardrails above,warnmeans an omittedsnapshot_monthdoesn’t block the query, only adds awarnings[]entry.
Assertions
Query-based, with expected values derived from the deterministic seed:gross-revenue-2025-q1→17814.00(paid, non-trial, non-refunded invoices, Q1)active-subscribers-2025-03→12
canonic assert runs them and reports accuracy (expected: 100%). See canonic assert.
Knowledge
knowledge/global/: bound to semantic entities via sl_refs:
mrr-definition(definition, with a live{{ sl:… }}template)semi-additive-mrr-caveat(caveat): never sum MRR across monthsrevenue-excludes-refunds-trials-caveat(caveat)revenue-finality-policy(policy): final vs. provisional revenueltv-methodology(policy): whycustomer_ltvisopaquevault-vs-mart(reference): when to use vault facts vs. data marts
Regenerating the warehouse
setup.sql is plain, deterministic DDL + seed data and can also be run directly through any DuckDB client: duckdb saas.duckdb < setup.sql.