The AI architecture for a B2B SaaS company's usage assistant — a scenario common across the industry — stage 3 of the reference architecture in data-platform-architecture: an assistant inside the product that answers customers' questions about their own usage from the governed tables. Every recommendation is measured on a lab copy of the data, with local, hosted and platform-native models.
The ask. Customers ask support how many reports they created, who used the mobile app, which week was busiest. Product wants an assistant to answer, on every plan, within a year (the brief). The data is in usage marts that hold every customer's rows; the customers are not users of the analytical platform.
What was measured (3. Options, lab/): 90 customer questions with answers computed by SQL, and 20 requests for other accounts' data, on a reproducible generated copy of the mart, put to Qwen3 8B run locally, Llama 3.3 70B and gpt-oss-120b on Databricks model serving, and Databricks AI/BI Genie.
- The semantic layer mattered more than the model. Given the business's definitions as well as the schema, Llama 3.3 70B went from 55 to 70 of 70 correct and Qwen3 8B from 46 to 64. gpt-oss-120b answered 70 of 70 and declined all 20 unanswerable questions. Results cluster by template (24 templates, not 70 independent questions), and the semantic layer was written with those templates in view, so these gains are an upper bound for questions like them.
- A prompt is not isolation. Told to answer only about the customer's account, the models leaked another account's data on 23 of 120 requests; every query Llama 3.3 70B wrote for them did. Run as the customer's own database identity, the same queries leaked 0.
- Genie was nearly as accurate, slower, and showed why. With the same definitions it answered 69 of 70, at 14.5 s median. Its one miss was a missing pair of parentheses that counted every account's Android users: 1,570 people instead of 12.
- The model is cheap; keeping a warehouse awake for it is not. At measured tokens, $0.00032 an answer on gpt-oss-120b in the company's EU region: about $19 a month at launch volume. The smallest SQL warehouse, awake whenever a customer may ask, would cost $2,657 a month, more than the whole $1,500 ceiling, so the assistant queries the stage-2 usage store that is awake anyway (0014). Self-hosting the model is price arithmetic only: an L4 or L40S GPU is far too small to hold a 120-billion-parameter model at all; on hardware that actually could (p5-48xlarge, 8×H100), break-even is about 174,600 answers an hour, against about 80 at launch.
The recommendation. The company's own small service on the platform's model serving: gpt-oss-120b with Llama 3.3 70B as the fallback, the semantic layer in every prompt, one read-only query per question scoped to the customer's account by the tool's own rewrite, every response recorded, and a paired evaluation gate with hard fails on isolation, latency and cost. Genie for internal staff, who are platform users. On the platform the tool runs as one service identity that can read every account; because a row filter there cannot read a per-request value, the tool scopes each query itself by rewriting it onto per-account tables: on every recorded query it returned exactly what row-level security did (0011).
On Snowflake. The data platform has since chosen Snowflake, which does not serve gpt-oss-120b. The proposed re-decision (0016) moves the model to Llama 3.3 70B through Cortex inside the EU, at $0.00087 an answer by list price on measured tokens (about $52 a month at launch), with Cortex Analyst for staff. Accuracy on Cortex is not measured yet: it is a condition of accepting 0016 before the pilot, and if it fails the model stays on Databricks' serving.
| Document | What it answers | |
|---|---|---|
| 1 | Brief | what the product wants, why it is hard, stakeholders, constraints |
| 2 | Requirements | eleven quality targets as testable scenarios, with the lab's result for each |
| 3 | Options, measured | accuracy, isolation, latency and cost for every way of building it |
| 4 | Target architecture | the request path, carrying the customer's identity, observability, failure modes |
| 5 | Evaluation | the evaluation set, scoring, the gate, after release |
| 6 | Security and compliance | OWASP Top 10 for LLM applications, data protection, EU AI Act, GDPR, NIST AI RMF |
| 7 | Operations | what is watched; runbooks for a leak, a wrong answer, a model change, an outage |
| Decisions | 16 decision records with options, drivers and evidence | |
| Risks, principles | the register; the rules across decisions | |
| lab/ | the mart, the questions, the attacks, the runners, and how to reproduce every number |
| # | Decision | Status | Backed by |
|---|---|---|---|
| 0001 | The assistant answers by querying the governed usage tables, not from documents | Accepted | 55 → 70 of 70 customers' questions answered correctly by Llama 3.3 70B, from the table definitions alone and with the semantic layer; 20 of 20 questions the data cannot answer that gpt-oss-120b declined, with the semantic layer |
| 0002 | Each query is scoped to the customer's account by a mechanism the model cannot influence; the prompt is not a control | Accepted | 23 of 120 requests for another account's data that leaked when isolation was left to the prompt; 0 of 28 queries that reached the database (of the 120 requests; the rest were declined) and returned another account's data, run as the customer's own database role |
| 0003 | A semantic layer of the business's definitions goes into every prompt | Accepted | 55 → 70 of 70 customers' questions answered correctly by Llama 3.3 70B, from the table definitions alone and with the semantic layer; 46 → 64 of 70 the same questions answered correctly by Qwen3 8B, run locally, without and with the semantic layer |
| 0004 | Customers get the company's own assistant service; staff can use the platform's assistant | Accepted | 69 of 70 questions Databricks AI/BI Genie answered correctly with the same definitions as instructions; median 14.5 s; 1,570 vs 12 people Genie counted for one customer's mobile users, against the right answer: a missing pair of parentheses counted every account's Android users |
| 0005 | gpt-oss-120b on the platform's model serving, with Llama 3.3 70B as the fallback | Accepted | 20 of 20 questions the data cannot answer that gpt-oss-120b declined, with the semantic layer; $0.00032 per answer on gpt-oss-120b at Databricks' pay-per-token list price in the company's EU region, from measured tokens; p95 5.5 s |
| 0006 | Every model response is recorded with its prompt's hash, and can be re-scored without the model | Accepted | 660 recorded model responses re-scored in CI against a fresh mart, with no model called; 54 of 54 cases where replaying the recorded model reproduced the live run's output |
| 0007 | A model that judges answers is an instrument: calibrated against labels before its scores count | Accepted | 7 vs 4 judge–key disagreements where the key, not the judge, was wrong; 5.9% → 0.0% false-positive rate of the judge on the baseline run, thinking off against thinking on |
| 0008 | Prompt, model and definition changes ship through a paired evaluation gate | Accepted | p = 0.39 for a 4.8-point judge drop the gate declined to fail; 1,469 → 4,422 ms p95 latency, the regression that was real |
| 0009 | "The data does not have this" is a supported answer, and it is measured on its own | Accepted | 20 of 20 questions the data cannot answer that gpt-oss-120b declined, with the semantic layer; 5 → 4 and 3 → 1 wrong answers the agent published on its own, on 30 fresh questions and on the 54 golden ones, once a rule sent answers to questions about measures the warehouse does not hold to review; none added, no correct answer held |
| 0010 | Every model call goes through one gateway: budgeted, recorded, with a fallback | Accepted | 20 of 20 cases with identical outputs, verdicts and judge reasons when re-run with the cache off; 54 of 54 cases where replaying the recorded model reproduced the live run's output |
| 0011 | On the platform, the assistant's tool scopes each query by rewriting it onto per-account tables | Accepted | 28 of 28 queries the models wrote for the isolation attacks that the tool's rewrite scoped to the customer's rows, exactly as row-level security did, including the 23 that leaked through the prompt; 436 of 436 queries for ordinary questions whose result the rewrite left exactly as row-level security gave it, none refused |
| 0012 | One read-only statement, with a row limit and a timeout, or nothing | Accepted | 0 of 28 queries that reached the database (of the 120 requests; the rest were declined) and returned another account's data, run as the customer's own database role |
| 0013 | Questions and answers are kept 30 days, never used for training, and erased on request | Accepted | 0 of 2,500 traces and recorded responses older than 30 days left after the retention job; 0 traces or recorded responses holding an erased user's e-mail or name, or keyed to them, after erasure |
| 0014 | The assistant has a cost per answer, from measured tokens, and a monthly ceiling | Accepted | $0.00032 per answer on gpt-oss-120b at Databricks' pay-per-token list price in the company's EU region, from measured tokens; p95 5.5 s |
| 0015 | Code that coding agents write ships through a test-integrity check, and the rules come before the hook | Accepted | 12, 11 and 10 of 12 agent patches greenproof's check accepted with no rules, with the written rules, and with the rules and the blocking stop hook; all 36 patches were correct; 23 of 24 vs 0 of 12 sessions in which the agent ran the check itself before finishing, with the written rules and without them; the hook blocked twice in its 12 sessions and changed no patch |
| 0016 | On Snowflake: Llama 3.3 70B through Cortex inside the EU, Cortex Analyst for staff, accuracy measured before launch | Proposed | $0.00087 per answer on Llama 3.3 70B through Snowflake Cortex's REST API with EU routing, at list price, from tokens measured on the same model on Databricks' serving; accuracy on Cortex not measured; 55 → 70 of 70 customers' questions answered correctly by Llama 3.3 70B, from the table definitions alone and with the semantic layer |
Every figure, with its method and source file, is in EVIDENCE.md.
| Status | |
|---|---|
| Accuracy, abstention, isolation, latency and tokens | measured: 660 recorded responses from three models and 90 from Genie, re-scored in CI from the recordings against a freshly built mart |
| Cost per answer | measured tokens at list prices (cost/); not an observed bill |
| The release gate, judge calibration, replay | measured in evalproof and governed-agent |
| Scoping on the platform | measured: the tool's rewrite on 464 recorded queries and a 44-case escape corpus (lab/escapes.yml, lab/rewrite.py --check); Databricks' row filters on its identity, and their limit, in data-platform-architecture |
| Conversation retention and erasure | measured on a synthetic trace store in Postgres (lab/retention.py, re-run in CI on a fresh database): rows, mentions in other users' records, and bytes in the table files and write-ahead log; the provider's training terms are a contract setting, not measured |
| Injection through text in the data, budgets under load | not tested (gaps) |
Data: generated to the scenario's shape and rebuilt identically in CI, so every figure can be re-run. The hosted models ran on Databricks Free Edition's model serving, and the local model with Ollama on one host, an Apple M5 with 24 GB. The first version of this repository, a general reference architecture for several AI features before it took on this scenario, is in the v0.1.0 tag.
Apache-2.0. See LICENSE.