Platform · Open reference architecture
Governed AI agents for data engineering
Spark Declarative Pipelines, Spark Connect, Kubernetes and a governed Iceberg REST catalog
Agents write pipeline specs; the platform decides what they are allowed to touch.
In one paragraph
Governed AI data engineering is an architecture in which AI agents author data pipelines but never hold direct power over data. The agent writes declarative Spark Declarative Pipelines specs as a pull request; CI dry-runs them against the real catalog; a controller applies approved changes. Each tenant reaches Spark only through one identity-pinned Spark Connect ingress behind mTLS, executors run as Kubernetes pods, and a governed Iceberg REST catalog authorizes every request and vends storage credentials scoped to that tenant. Each layer owns one job, so a mistake in one does not become a breach in another.
Platform
Spark Declarative Pipelines, Spark Connect, Kubernetes and a governed Iceberg REST catalog
Sources
Ingestion
Open lakehouse platform
Engine access
How agents, apps and people reach compute: a client session per identity.
Execution
Spark's execution modes, plus engines that read the same tables.
Data foundation
Open tables in a governed catalog, on storage you own.
Governance
Operations
Serving
Teams
When to use it
- You want AI agents to build or change pipelines without giving them production credentials.
- You need per-tenant isolation on shared Spark infrastructure.
- You want defects caught before any data is processed.
When to pick something else
- A single-user sandbox: the masterclass's local agent chapter is the lighter starting point.
Walkthrough
How data moves through it
- 1
Agent proposes
The agent writes Spark Declarative Pipelines specs and opens a pull request; it has no direct write path.
- 2
CI dry-runs
CI runs the pipeline in dry-run mode against the real catalog, catching structural defects before any data is processed.
- 3
Identity-pinned ingress
The tenant's client certificate reaches Envoy, which routes by its SPIFFE URI SAN to that tenant's Spark Connect server.
- 4
Executors run
Kubernetes schedules executor pods that do the work.
- 5
Catalog authorizes
Lakekeeper with OpenFGA authorizes each table operation and vends STS credentials scoped to the tenant's prefix.
Bill of materials
Components and versions
| Capability | Component | Role in this architecture | Version | License |
|---|---|---|---|---|
| SourcesSource systems | AI coding agent | Writes inert pipeline specs as a pull request | ||
| AI and agentsAgent harness and policy | Omnigent | Agent harness with tools and policies | ||
| AI and agentsModels and gateway | Ollama | Local model for the course's agent chapter | MIT | |
| Engine accessSpark Connect sessions | Spark Connect | The single identity-pinned ingress per tenant | 4.1.2 | Apache-2.0 |
| ExecutionBatch and SQL | Apache Spark | Executors do the work | 4.1.2 | Apache-2.0 |
| ExecutionDeclarative pipelines | Spark Declarative Pipelines | Declarative authoring: specs, not imperative jobs | Spark 4.1.2 | Apache-2.0 |
| Data foundationCatalog and credentials | Lakekeeperor Unity Catalog OSS, Apache Polaris | Governed Iceberg REST catalog with per-principal authorization and credential vending | 0.13.1 | Apache-2.0 |
| Data foundationOpen table format | Apache Icebergor Delta Lake | Tables under per-tenant prefixes | 1.11.0 | Apache-2.0 |
| Data foundationObject storage | Amazon S3or MinIO | Data under per-tenant prefixes with STS-scoped credentials | ||
| GovernanceAccess control and policy | Envoy | mTLS on :15009; routes each client certificate to its tenant | 1.31.5 | Apache-2.0 |
| GovernanceAccess control and policy | OpenFGA | Authorization model behind the catalog | 1.14.0 | Apache-2.0 |
| OperationsRuntime, CI/CD and IaC | GitOps CI gate | PR-only output, dry run against the real catalog, reconcile | ||
| OperationsRuntime, CI/CD and IaC | Kubernetes | Client-mode driver plus executor pods on EKS | EKS 1.31 | Apache-2.0 |
People and agents
Who works with it
Data engineers
Pipelines that are correct, idempotent and cheap to rerun.
Works with: Batch and SQL, Declarative pipelines, Open table format
AI agents
Tools with clear arguments, a sandbox to write into, fast feedback from dry runs, and version-pinned context.
Works with: Spark Connect sessions, Declarative pipelines
ML and AI engineers
Reproducible models, traced and evaluated agents, and a model gateway they control.
Works with: Models and gateway, Agent harness and policy
Analysts and analytics engineers
One definition of each metric, fast SQL, and dashboards that match.
Works with: Batch and SQL
Platform engineers
A platform that is boring to run: deployable from code, observable, with identities for every person, service and agent.
Works with: Object storage, Catalog and credentials, Runtime, CI/CD and IaC, Spark Connect sessions
Governance and security
Policies that hold in every engine and for every agent, lineage for audits, and least privilege by default.
Works with: Access control and policy, Catalog and credentials, Agent harness and policy
Run it
Reference code
Working paper, reproducible study and open reference architecture for safe, governed AI data engineering on Apache Spark.
cd study
python3 analysis/analyze.py results/results.powered.AB.n12.final.jsonl --tasks config/TASKS.lock.json --assume-backend localChapter 3 runs an agent on Omnigent with a local Ollama model, MCP tools and ALLOW, DENY and ASK policies; chapter 13 has a coding agent operate the stack through AGENTS.md.
Early-stage agent skills for the open lakehouse, driven by a connection profile instead of hardcoded hosts (lakehouse-core ships today).
Caveats from the reference repos
- The isolation proof runs on one Spark Connect server per tenant; a shared-server design is described as frontier work in the paper.
- The five isolation links are proven one at a time, not as one composed request.
- Unity Catalog OSS 0.5.0, evaluated as an alternate catalog, could not do per-principal authorization on its Iceberg REST path.
Industry lenses
Where this architecture shows up
Each card opens the board with that industry's sources. Full industry pages: Payments and fintech, Cybersecurity.
Answers
Frequently asked questions
- How do you let AI agents build data pipelines safely?
- Give them a declarative output and no direct path to data: the agent writes Spark Declarative Pipelines specs as a pull request, CI dry-runs them against the real catalog, and execution happens through an identity-pinned Spark Connect ingress with a catalog that authorizes every table operation.
- Do declarative pipelines catch more agent mistakes?
- In the safe-spark-agents study (528 runs: 22 tasks, 12 seeds, 2 arms), the Spark Declarative Pipelines dry run caught 79 structural defects before any data was processed, against 0 for the imperative arm. SDP output was 49% fewer lines at about 2.3 times the tokens.
Related architectures
All architecturesPlatform
The agentic lakehouse
Omnigent and MLflow over sandboxed Spark Connect sessions, on Iceberg and Unity Catalog
Platform
The open lakehouse on a laptop
Spark 4.3, Apache Iceberg, Unity Catalog, Kafka, Airflow, MLflow and an agent, in Docker
Streaming
Streaming medallion
Kafka, Spark Structured Streaming and Apache Iceberg in Unity Catalog
