Medallion Architecture with AI Agents: Governing Business Rules from ERP to Power BI
- The problem with connecting Power BI directly to the database
- Medallion Architecture with AI Agents: From Bronze to Business Rules
- Overwatch: the AI Agent That Guards Knowledge Without Touching Code
- Git Worktrees and Human Oversight: How to Work in Parallel Without Stepping on Each Other
- Frequently asked questions
A Power BI report stops adding up overnight, and nobody on the team knows what changed, when it happened, or who approved it. This happens constantly in data projects that grew by connecting reports directly to the ERP database.
The query is instant, and the report shows up in minutes, so for a while nobody notices anything missing. The problem appears when a table changes shape, a metric gets recalculated under a different criterion, or someone corrects a historical record without telling anyone: that change slips into every report connected live, with no traceability and no way to go back.
The medallion architecture with AI agents I explain in this article was built to close that gap: govern the data before it reaches any report, and let agents — not people — watch over whether business rules are being followed at every layer.
The problem with connecting Power BI directly to the database
Almost every data project starts the same way: the business asks for a report, someone sets up a connection, writes a query against the ERP, and before long that report is live in production, drinking straight from real-time data. This direct route has a real advantage: it’s extremely fast, with no intermediate layers to maintain and no processes to orchestrate.
The cost shows up once that report has been in production for months and something changes at the source. With a direct hit on the database, a change like that propagates with zero control:
- There’s no traceability over who changed what, when, or why.
- History gets lost: there’s no way to compare a current state against a previous one.
- There are no versions either, so rolling back to a valid state stops being possible.
Let me walk you through the situation to illustrate the problem: a Power BI report feeds off a query that calculates a metric in a specific way. If that metric changes at the source, the report breaks or falls out of sync, and every other report using the same logic needs to be updated by hand, one by one, across every source that replicates it.
Follow our journey building AI agents from the inside
That’s where the need to govern information comes in: a data warehouse, a data lake, or any data management system that lets you build a layer of history and versions, roll back to previous states, and validate that business rules make sense both going forward and over what’s already been generated. I’ve written before about what it takes to migrate reports that were born connected directly to the source, and the starting point is always the same: with everything governed in a single hub, every report, inference, and analysis speaks the same language—no more Tower of Babel.
Medallion Architecture with AI Agents: From Bronze to Business Rules
The structure we built to solve this starts with Azure Data Factory, which orchestrates data collection from the source systems. From there, information is organized into three layers — what’s known as medallion architecture:
- Bronze layer: data arrives raw, exactly as it comes out of the source, with no curation at all.
- Silver layer: a first validation pass runs (nulls, records broken by processing, incomplete data), and the result comes out clean but without business logic yet.
- Gold layer: business rules get applied here, which lets anyone with functional knowledge run analytics and inferences on data that’s already validated.
All of this processing happens in Databricks, which works as the engine that cooks that gold layer before Power BI puts it to work in the final reports. Databricks’ own documentation on medallion architecture describes the same layered pattern we follow here.
Two more pieces live outside this flow, but they’re what hold the whole system together. On one side, a knowledge repository (Notion or, depending on the project, Obsidian) where the logic layer lives separate from the code: the business rules, the knowledge descriptions, and the decisions made. On the other side, GitHub, which provides versioning on top of those rules: who made a decision, when, and how, with the option to revert it.
Separating these pieces isn’t a technical whim. If everything lived on the same platform, anyone with business knowledge would need access to the code and the data just to contribute. By decoupling it, work can be split across different profiles, development can happen in parallel without fear of stepping on each other, and — above all — you can pick whichever AI model fits best at any given moment without exposing sensitive information to a provider that might use it to train its own models.

Overwatch: the AI Agent That Guards Knowledge Without Touching Code
To orchestrate the code agents, we built a role we call Overwatch: a director agent that loads the entire knowledge base about the data model and hands out tasks, but never touches a single line of code.
Overwatch’s only job is being the custodian of knowledge. It keeps the data models loaded and generates specific tasks so the code agents don’t get handed all that business context every time: they work with small, scoped context files limited to what they need to solve, and when they’re done, the result goes back to Overwatch for review. This separation keeps the code agents’ context from filling up with information they don’t need, and it adds a second layer of review that catches logic flaws that slipped through the initial design.
It’s the same logic an architect applies when reviewing a house design: the cantilevered room looks spectacular on the blueprint, but someone has to point out that it can’t hold two tons with no support underneath. The code agents run that second check on the tasks Overwatch generates, so errors neither of them would have caught alone get stopped before reaching production.
Everything Overwatch learns along the way gets fed back into the knowledge repository, which makes it possible to bring up a second profile at any point with full access to that knowledge from minute one. Our colleague Lita García recently wrote about what it takes beyond just defining rules for an agent to follow them, and this double-check is exactly how those rules get put into practice, beyond just a document.
A design that makes business sense on paper, but runs into flaws once it hits implementation.
ÁLVARO GONZÁLEZ-IGLESIAS
Data Engineer
Git Worktrees and Human Oversight: How to Work in Parallel Without Stepping on Each Other
When several code agents attack the same data environment at once, the obvious risk is that they step on each other. To avoid that, we use git worktrees, which let each task work on its own copy of the repository without interfering with the others.
This way of splitting up the work is what lets a job that used to require six people, each with their own task assigned exclusively, get tackled simultaneously. The only thing left to check is that each task’s logical plan is correct, that it has the expected structure, and that the runs return the data they were supposed to.
General business rules don’t live inside each code task: they live in Overwatch’s memory, which shares with each task only the fragment of context it needs. This cuts token consumption, keeps any single agent’s context from getting overloaded, and lets tasks sync up with each other every time one finishes and goes back through Overwatch.
The human role here does different work than it used to: now it supervises the coherence of the orchestration and the outputs, instead of reviewing line by line whether the code is well written. That shift in role is what makes it possible to go from managing one task at a time to managing several developments in parallel, with a task board where each one carries a summary reminding you what’s being touched, so you don’t lose the thread across five or six open fronts at once. The firmer this foundation, the faster you can keep building on top of it without tripping over your own earlier work.

What we’re still fine-tuning now is the granularity of those tasks: how much context a code agent really needs to solve a business rule without Overwatch having to repeat everything from scratch, and how much more speed can be gained without losing human oversight over the coherence of the whole. Every problem we run into gets documented in that shared context, so the next round always starts a little further ahead than the last one.
Frequently asked questions
What is a medallion architecture with AI agents?
It’s a three-layer data architecture (bronze for raw data, silver for validated data, and gold for data with business rules applied) where AI agents watch over whether those rules are being followed at every layer. The rules live in a knowledge repository separate from the code and are versioned in GitHub, so every decision stays traceable and can be reverted.
Why not connect Power BI directly to the ERP database?
A direct connection is fast, but any change at the source propagates to every report with zero control: there’s no traceability of who changed what, history gets lost, and there are no versions to roll back to. With a governed layer between the ERP and Power BI, every report draws from the same validated logic, and a change can be audited or reverted.
What does a director agent like Overwatch do if it doesn’t write code?
It guards the knowledge about the data model, hands code agents tasks with exactly the context each one needs, and reviews the result when it comes back. That separation cuts token consumption and adds a second review layer that catches logic flaws before they reach production, while the person on the team supervises the coherence of the whole.