Governed Datasets vs Direct Database Queries for Agents
Governed datasets prevent agents from confidently delivering wrong answers.

Giving an AI agent a database credential and a prompt feels like the fastest route from a question to an answer, and in a narrow sense it works: the model writes syntactically correct SQL, the query runs, a result comes back. The trouble is that this setup produces three compounding structural failures, each one independent of model quality, that make unreliable output nearly inevitable once the agent is pointed at a production schema.
Why giving agents direct database access produces structural failures
The logic behind direct access is straightforward enough to feel self-evident. Modern models genuinely do write serviceable SQL, often cleaner than what a tired analyst would type at 4 p.m. on a Friday.
The failure has nothing to do with syntax. An agent can write a flawless JOIN across five tables and still return the wrong answer, because writing correct SQL and understanding what the business means by "revenue" or "active user" are two separate problems, and only the first one is solved by giving the model more context window or a better prompt. The second problem is structural: ambiguity in what the schema actually means, disagreement over what a given metric is supposed to measure, and the collapse of access control once SQL is generated dynamically rather than written by a known person. Each of these gets worse, not better, as the agent gets faster and more capable, because speed amplifies a wrong assumption as efficiently as it amplifies a right one.
Atlan's 2026 guide on AI agent data access describes the pattern that produces most of this exposure in practice: a pilot project needs data quickly, so someone provisions a broad credential to get it unblocked, and that credential's reach quietly becomes the agent's permanent reach because nobody goes back to scope it down once the pilot succeeds. The credential was meant to be temporary, but it never is.

Schema ambiguity: why agents guessing at table semantics get confidently wrong answers
Schema complexity isn't something a better prompt fixes, because the mismatch is structural: production databases are built for writing data efficiently, not for making its meaning legible to a reader who wasn't there when the table was designed. None of that is a flaw in the database; it's just not what the database was built to do.
When an agent runs into three or four columns that could plausibly be "revenue," it has no principled way to pick the right one. The problem is what happens when it doesn't: the agent doesn't hedge or flag uncertainty, it returns a fluent SQL query and a clean, well-formatted result, and that result looks exactly as trustworthy as a correct one would. There is no visible seam between a right answer and a confidently wrong one.
Anthropic's own internal setup is a useful data point here. The stack starts from modeled data and curated metric definitions, and internal evaluations run without that scaffolding showed accuracy well below what was achievable once the agents had defined "skill files" to work from. That gap reflects agents guessing at table semantics without defined meanings in a controlled setting.
Column and table names have to be mapped to business-language definitions before an agent can reason about them with any reliability, and that mapping work is a data modeling exercise, not a prompting trick. This is exactly what pre-modeled datasets are built to do: wrap the raw complexity of a production schema in a curated, documented layer that an agent can query with confidence instead of guessing, which is the approach Dreambase takes by presenting agents with modeled data rather than raw tables.
Metric inconsistency: what happens when no single definition owns the number
Once several agents or dashboards can each compute the same metric from raw tables, the business ends up with competing numbers and no built-in way to decide which one is correct.
Monthly Recurring Revenue is a clean example because almost every company tracks it and almost every company computes it slightly differently depending on who's asking. Finance might calculate MRR from the billing table with one set of filters. None of them agrees with the others.
This isn't a data quality defect in the usual sense, since the underlying rows are accurate. The real issue is that no single definition owns the metric, so three correct interpretations of incomplete instructions produce three different totals. Left unaddressed, this turns into metric drift: departments quote different performance numbers in the same meeting, and trust in the data itself starts to erode across the company, which is a slower and more corrosive cost than any single wrong query.
The principle that follows is simple: a metric needs one definition, calculated once, in one place, consumed by every agent, dashboard, and person downstream as a pre-calculated result. Pre-calculation here isn't just about speed; it is what makes a metric's definition something enforced by the system rather than something hoped for in a style guide nobody reads.
Unenforceable access control: why application-layer permissions break down under dynamic SQL
Access control has historically lived in the application layer, built on the assumption that queries come from a known piece of code or a human who can be held accountable for what they ask. That assumption doesn't survive contact with an agent that constructs SQL dynamically at machine speed, because there's no practical way to review or test every query before it runs.
The mechanical consequence is blunt: whatever table a credential can reach, the agent holding that credential can reach too, and at agent speed, every gap in naming, every gap in permissions, and every unresolved metric conflict gets found far faster than it would be found by a person clicking through a reporting tool. The decision about what an agent should be allowed to see has to happen in a governed layer sitting between the agent and the raw data, not inside the protocol that moves the request.
There's a regulatory dimension to this too. Least privilege isn't only good security hygiene for AI agents, it's a direct requirement under GDPR's data minimization principle, laid out in Article 5(1)(c), which requires personal data to stay adequate, relevant, and limited to what's necessary for the purpose it's processed for. Oracle's announcement of Oracle Deep Data Security in AI Database 26ai named agents being manipulated into executing SQL that exposes sensitive data as precisely the threat the product was built to address, a signal that the industry has already concluded application-layer enforcement alone isn't enough to contain agent behavior.
If governance can't live in the application layer once agents are issuing the queries, it has to live in the data layer itself. That's the argument for governed datasets, and it's where the diagnosis ends and the design pattern begins.
What governed datasets are
A governed dataset is a pre-modeled, policy-enforced representation of data that an agent queries in place of the underlying tables. It addresses schema ambiguity through semantic naming, metric inconsistency through pre-calculation, and access control through enforcement built into the structure of the data itself rather than assumptions made at the application layer.
A governed dataset is a surface shaped deliberately, ahead of time, for consumption by both people and agents.
Schema ambiguity gets resolved because columns and tables carry business-language names and definitions decided once, at modeling time. An agent working from a governed dataset reasons about "monthly recurring revenue," not sub_amt_v3_adj, because the translation between the two was done by someone who understood the business logic, not re-attempted by the model at query time under uncertainty. Metric inconsistency gets resolved because the metric is calculated once, on a schedule, stored as a result, and exposed as a fact rather than a formula every consumer has to reconstruct. Access control gets resolved because permissions are enforced at the dataset boundary, not at the credential level. An agent that can reach the dataset sees only what the dataset is built to expose, regardless of what else sits in the underlying database.
This maps cleanly onto the medallion architecture already familiar to most data teams: a Bronze layer of raw, ingested data that no agent should ever query directly, and a Gold layer of governed, business-ready datasets, which is the only layer where agent queries should land. Anthropic's internal production stack confirms the pattern works in practice: when a question maps to a defined metric, the agent calls a function and returns the same number every other surface in the company would produce, and raw SQL only gets used as a fallback when no defined metric exists, never as the default path.
How MCP connects agents to governed datasets
MCP standardizes how an agent asks a tool or system for data, but the protocol itself doesn't make that data correct or that access safe. Those two properties have to come from whatever governed layer the MCP server is sitting in front of.
The Model Context Protocol, introduced by Anthropic in November 2024, is an open standard that defines how AI applications connect to external tools and data sources, replacing a sprawl of one-off integrations with a single shared interface. A governed MCP server differs from an ungoverned one because it sits in front of a governed layer, carries that layer's policy with it, and scopes exactly what the agent is permitted to see.
MCP moves data and actions toward the agent, and a governed dataset is what makes that data correct and safe to move. Strip out the governed layer, and MCP just delivers the same three structural failures, schema ambiguity, metric inconsistency, and unenforceable access, at higher speed and lower friction than before.
There's already platform-level validation of this pattern. Google shipped fully managed MCP servers for Maps, BigQuery, Compute Engine, and Kubernetes Engine in December 2025, and each of those servers sits in front of a governed layer. The safest way to start building on this pattern is with read-only resource servers: a read-first MCP tool that retrieves governed data for analysis carries far less risk than one with write access, and write actions can be added later, gated behind explicit change approvals, once the read path has proven itself.
Dreambase's implementation follows this shape closely. Agents query modeled Parquet datasets running on DuckDB through a single MCP server, and production databases are never touched directly, every query lands on the governed layer instead. The choice of Parquet and DuckDB matters specifically for agent workloads: columnar files support fast analytical scans at low cost, and agents can work from summarized results instead of raw row-by-row data, cutting both token consumption and latency at the same time.
What the governed layer needs to enforce
A governed dataset earns trust through real policies: a named owner, a sensitivity classification, scoped row- and column-level access tied to who or what is asking, and a complete audit trail of every query an agent runs. Without those, "governed" is just a label on top of the same raw access problem.
Before any agent touches a dataset, a short checklist needs to be satisfied: a named owner, a sensitivity classification, documented source lineage, an access policy, and a retention policy. Define the policy against a governed metadata layer first, and only then expose data to agents through an MCP server that carries that policy with it.
Agents need to be governed the way people are governed. A full audit trail is the only reliable way to reconstruct afterward what an agent actually did and why.
Row-level security still matters, but applying it naively to live queries against production carries a real performance cost. A governed dataset that pre-filters down to the rows a given caller is permitted to see, before the agent ever runs a query against it, sidesteps that tradeoff entirely rather than forcing a choice between speed and safety. The solution here is to replace dynamic SQL against production with a static, pre-modeled dataset surface, one where access control is enforced at the data boundary before the agent ever runs a query. Serving agents curated Parquet datasets through a governed API, rather than handing out direct database credentials, lets a team audit and revoke access at the governance layer itself, which keeps agents operating inside policy rather than at the full reach of whatever credential they happen to hold.
Applying this pattern with Supabase and Postgres, without a data warehouse or a data team
Teams already running on Supabase and Postgres don't need to migrate to new infrastructure to adopt this pattern. Postgres is already functioning as the analytical home for the business, and the governed layer extends outward from it.
Treating Postgres purely as a source to extract from and standing up a separate warehouse alongside it is a mistake to avoid. A governed layer built directly on top of the Postgres instance a team already runs solves for all three without requiring a new platform, a new pipeline, or a dedicated data engineering function to maintain it.


