Talk with our engineers by joining the new Onehouse community Slack!

AI Data Layer

Semantic Layer

A schema does not tell an agent what your metrics mean, so it guesses. With a semantic layer, every agent gets the same, reproducible answer to the same question, about 3× faster and at 40% lower cost per answer.

Raw tables pass through the semantic layer, which applies certified metrics, join paths, business filters and access policies. The AI agent receives one answer with its metric version, resolved dates and SQL.
Questions from
People and agents, through two AI Gateway tools over MCP: search metrics and query metrics
Queries run on
Lakegres, read-only, as the user who asked
Definitions
Metrics, dimensions, relationships, descriptions and synonyms
Format
Exports to Apache Ossie (incubating), the open specification that began as Open Semantic Interchange
Stored in
The Onehouse catalog, as numbered published versions that are also written to your object storage

What you get

  • Same question, same SQL

    Source tables, business filters, join paths and exact date ranges come from the certified definition. The model only picks the metric, the dimensions and the time range.

  • Asks when a question is ambiguous

    When a question could mean more than one thing, such as mean or median build duration, the agent asks which one. When no certified metric fits, it says so.

  • Joins that do not double-count

    Joins follow the declared keys. An order with three line items has its amount counted once.

  • Answers show their derivation

    Each answer carries the metric and its version, the resolved dates, and the SQL that produced it. Every answer is audited.

  • Governed like any other query

    A question is matched only against metrics the user may see, and the query runs under the governance catalog policies.

  • Built from the documents you already have

    OneFlow, or a Spark job on Quanton, parses your runbooks, wikis and metric documentation into open tables. A coding agent such as Claude Code or Codex reads them next to your table schemas and drafts semantic models for an engineer to review.

Measured

  • 68% → 84%

    fully correct answers on 25 business questions, the same model working from raw data against the semantic layer

  • 18 s

    median answer time with the semantic layer, against 52 s working from raw data

  • ~$0.16

    reported cost per answer with the semantic layer, against about $0.27 working from raw data

From a question to a governed answer

Ask

  • User or agentA question in natural language

Route

  • AI Gateway

Resolve

  • Semantic modelsCertified metrics the user may see. Asks back when a question is ambiguous.
SQL from the definition

Run

  • LakegresRuns the SQL as the user, under governance policies

Answer

  • Governed answerWith the metric version, dates and SQL, audited

The same question returns the same SQL

A semantic model holds the business rules the schema does not: which table holds net revenue, which orders to exclude, what last quarter means. Teams write the model as YAML in the console, validate it and publish it.

  • Metrics of every shape. Simple totals, ratios, derived, cumulative and conversion metrics, with business filters built in.

  • Certified and versioned. A draft is validated together with every other published model, then published as a numbered version. An older version can be made active again.

Semantic model editor showing YAML definitions, Save and validate, and the published version status.

Build your semantic layer from your own documents

Metric definitions often already exist in runbooks, wikis and metric documentation. Unstructured data processing parses those documents into an open table with their text and embeddings, and a coding agent drafts semantic models from them.

  • Retrieved next to the schemas. The agent finds the relevant passages through Lakegres vector search or text search while it inspects the table schemas.

  • Reviewed before it is published. An engineer checks each draft against the operating rules. An admin validates and publishes it in the console or with the oh semantic import CLI.

  • Maintained from agent traces. Traces the AI Gateway records show which metrics agents use and which questions have no certified metric, so the team knows what to add next.

  1. 1IngestOneFlow or a Spark job parses runbooks and metric documentation into an open table.
  2. 2RetrieveA coding agent searches those passages and the table schemas.
  3. 3DraftThe agent writes a semantic package in YAML.
  4. 4Review and publishAn engineer reviews it, and an admin validates and publishes a new version.
  5. 5MaintainAgent traces show which metrics to add or correct next.

Asked through the AI Gateway, answered by Lakegres

Agents search and query published metrics through the AI Gateway. The catalog compiles each metric request into SQL, and Lakegres runs it read-only as the user who asked.

  • Filters callers cannot remove. A metric's built-in filters always apply. Filters added to a request are parsed against a small grammar, and no SQL text written by the caller reaches the engine.

  • Row and column policies apply. The query is authenticated as the user who originated the request, so that user's row filters and column policies apply.

An AI agent asks a question. AI Gateway gives it tools to search and query metrics. The catalog compiles the request into SQL from published semantic models. Lakegres runs it read-only as the asking user on open tables, and a governed answer returns to the agent.

Frequently asked questions

What is a semantic layer, and why do AI agents need one?

A semantic layer is a set of definitions that maps business terms to the tables underneath. It names the metrics a company reports, how each one is calculated, the dimensions it can be grouped by and how the tables join. An agent that reads only column names and sample rows has to infer those rules, such as whether retries count as separate builds, and two agents can infer differently. With a semantic layer in the path, the agent picks a metric, dimensions and a time range from a published list, and the SQL is generated from the definition.

How do agents query metrics in the Onehouse semantic layer?

Agents use two tools that the AI Gateway serves over MCP (Model Context Protocol): one searches the published metrics and one queries them. The Onehouse catalog compiles each metric request into SQL from the published definition. Lakegres, the Postgres-compatible SQL engine in Onehouse, then runs that SQL read-only under the identity of the user who asked. The answer returns with the metric and its version, the resolved dates and the SQL that produced it.

How are semantic models written, validated and versioned?

Semantic models are YAML files. Teams edit them in the Onehouse console, import up to 20 files at a time, or upload them with the oh semantic import CLI from their code-review workflow. Validation compiles a draft together with every other published model and confirms that the tables and columns it references exist, so two teams cannot publish different metrics under the same name. Publishing creates a numbered version and records the publisher and the time. An admin can activate an older version again to roll back a change.

How much does a semantic layer improve AI agent accuracy, speed and cost?

In the published Onehouse evaluation, the same Claude Opus 5.5 model answered 21 of 25 curated business questions fully correctly (84%) through the semantic layer, against 17 of 25 (68%) working from raw data. The median answer took 18 s against 52 s, and reported cost per answer was about $0.16 against about $0.27. The data was 30 tables and 1.37 million records of Onehouse operations data. The semantic configuration used 21 semantic models and 84 metrics prepared ahead of time with this question set in mind, and each configuration ran once per question. The launch post has the method.

Can a coding agent build semantic models from existing documentation?

Yes. A OneFlow pipeline, or a Spark job on Quanton, parses runbooks, wikis and metric documentation and writes their text and embeddings into an open table, as described under unstructured data processing. A coding agent such as Claude Code or Codex retrieves the relevant passages through Lakegres vector search or text search, inspects the table schemas, and drafts a semantic package in YAML. An engineer reviews the draft against the team's operating rules before an admin validates and publishes it.

What format can Onehouse semantic models be exported in?

Semantic models export to Apache Ossie (incubating), the open specification that began as Open Semantic Interchange. Teams use the export to carry their metric definitions between platforms. Each published version is also written as a file to object storage in your own account, next to your data.

How is access enforced on semantic layer queries?

Lakegres runs each metric query read-only under the identity of the person who asked, so the row filters and column policies set for that person in the governance catalog apply to the answer. A question is matched only against the metrics that person is allowed to see. Callers cannot remove a metric's built-in filters. Any filter a caller adds is parsed against a small grammar, which keeps caller-written SQL text from reaching the engine. Every answer is audited.

From the blog

Give each metric one answer

A language model writing SQL directly against your tables can return a different number each time the same question is asked. Certify one metric, ask for it in natural language, and check the SQL and the derivation that come back with the answer.