How it's built on Databricks
Everything ships as one Asset Bundle: synthetic data generator → serverless Lakeflow Declarative Pipeline (medallion: bronze → silver → gold in Unity Catalog) → Genie space → Databricks App.
Pipeline expectations enforce correctness. Every temporal invariant is a `@dlt.expect_all_or_fail` expectation — twenty of them. A violation fails the run instead of quarantining rows, because these rules *are* the product's correctness. Example: derived percentages are NULL, never a `9999` sentinel, because Genie will happily average a sentinel into a mean.
The Genie space is code. Instructions, example queries and trusted-asset Unity Catalog functions live in one Python module, rendered both as markdown for review and as the `serialized_space` JSON pushed via the REST API. One source of truth, so the docs and what Genie was told can't drift.
Genie is tested like software. There's no benchmark API, so I built a contract suite. Since scenarios are planted at known effect sizes, I know the right answer to every question independent of whatever SQL Genie writes. Fifteen contracts assert on results — must-include/must-exclude policy sets, orderings, negative checks — each run three times. 3/3 is green; anything else is red, no retries. A 2/3 means Genie is choosing between readings of the question, and that instruction ambiguity gets fixed, not retried.
Unity Catalog is the whole authorization story. The app declares `user_api_scopes` (`dashboards.genie`, `sql`), and Databricks Apps forwards each viewer's token as `x-forwarded-access-token`. Every Genie call and query runs *as the viewer*, so I wrote no authorization layer — UC grants decide everything, and a viewer without grants gets a clean "ask your admin" state.