Capstone 5: Multi-Agent Lakehouse Governance Team
+---------------------------------------------------------------------------------+
| PROJECT 5 ARCHITECTURE |
+---------------------------------------------------------------------------------+
| [TEAM SUPERVISOR] |
| (Orchestrates tasks) |
| / | \ |
| v v v |
| [CATALOGER] [SECOPS] [FINOPS] |
| Documents Audits Optimizes |
| Schemas PII/RBAC Storage/Compute |
| \ | / |
| v v v |
| [UNIFIED AUDIT REPORT] |
+---------------------------------------------------------------------------------+
Objective
Build a multi-agent system using LangGraph where three specialized AI agents collaborate to review a newly provisioned lakehouse table:
- Cataloger Agent: Generates column documentation and lineage tags.
- SecOps Auditor: Checks for unmasked PII, SSNs, credit cards, or excessive read privileges.
- FinOps Optimizer: Recommends partitioning columns, clustering keys, and Z-ORDER strategies to minimize cloud warehouse queries.
Complete Multi-Agent Workflow Implementation
from typing import TypedDict, List
from langgraph.graph import StateGraph, END
from openai import OpenAI
client = OpenAI()
class GovernanceState(TypedDict):
table_name: str
ddl: str
catalog_notes: str
security_verdict: str
finops_recommendations: str
final_report: str
# Agent 1: Cataloger
def cataloger_node(state: GovernanceState) -> dict:
prompt = f"Document this table schema concisely:
{state['ddl']}"
res = client.chat.completions.create(model="gpt-4o-mini", messages=[{"role": "user", "content": prompt}])
return {"catalog_notes": res.choices[0].message.content}
# Agent 2: SecOps Auditor
def secops_node(state: GovernanceState) -> dict:
prompt = f"Audit this table DDL for PII risks (emails, phones, credit cards):
{state['ddl']}"
res = client.chat.completions.create(model="gpt-4o-mini", messages=[{"role": "user", "content": prompt}])
return {"security_verdict": res.choices[0].message.content}
# Agent 3: FinOps Optimizer
def finops_node(state: GovernanceState) -> dict:
prompt = f"Recommend clustering and partitioning strategies for this table:
{state['ddl']}"
res = client.chat.completions.create(model="gpt-4o-mini", messages=[{"role": "user", "content": prompt}])
return {"finops_recommendations": res.choices[0].message.content}
# Agent 4: Supervisor Synthesizer
def supervisor_node(state: GovernanceState) -> dict:
report = f"""
# Data Lakehouse Governance Report: {state['table name']}
### 1. Catalog & Documentation
{state['catalog_notes']}
### 2. SecOps & Compliance
{state['security_verdict']}
### 3. FinOps & Performance Recommendations
{state['finops_recommendations']}
"""
return {"final_report": report}
# Build LangGraph
workflow = StateGraph(GovernanceState)
workflow.add_node("cataloger", cataloger_node)
workflow.add_node("secops", secops_node)
workflow.add_node("finops", finops_node)
workflow.add_node("supervisor", supervisor_node)
workflow.set_entry_point("cataloger")
workflow.add_edge("cataloger", "secops")
workflow.add_edge("secops", "finops")
workflow.add_edge("finops", "supervisor")
workflow.add_edge("supervisor", END)
app = workflow.compile()
print("Multi-Agent Governance Graph successfully compiled!")