Skip to main content
This example builds a DevOps AI agent that manages service deployments, database migrations, firewall rules, and cluster scaling. A custom infrastructure domain profile (created by you using the domain profile framework) can enforce SOC 2 and ISO 27001 compliance by detecting production environment operations, requiring multi-party approval for deployments, and protecting against unverified rollbacks.

What You Will Build

  • A deployment agent that gates production releases with multi-party approval
  • Database migration management with DBA sign-off
  • Firewall rule changes with teach-back verification
  • Rollback protection that prevents panic-driven emergency changes
  • Both Python and TypeScript implementations using LangGraph

Configuration

Create an attesta.yaml in your project root:
attesta.yaml
A custom infrastructure domain profile might set a production_multiplier of 1.6. A deployment scored at 0.55 (MEDIUM) in staging would then become 0.88 (CRITICAL) in production, triggering multi-party approval. This is intentional — the same operation carries fundamentally different risk in production. See Custom Domains for how to create your own domain profile.

Python Implementation

1

Install dependencies

2

Define the infrastructure tools

Each function is gated by Attesta. A custom domain profile can be configured to detect deployment operations, database commands, firewall changes, and privilege escalation.
infra_agent.py
3

Build the agent loop with LangGraph

This agent uses LangGraph with Attesta inserted as a gate node between the agent and tool execution.
infra_loop.py
4

Run the agent


TypeScript Implementation

1

Install dependencies

2

Build the infrastructure agent

infra-agent.ts
3

Run the agent


Expected Terminal Output

Scenario 1: Service Status (LOW — auto-approved)

Read-only status check. No deployment or destructive patterns match. Auto-approved silently.

Scenario 2: Staging Deployment (MEDIUM — confirm)

The deploy keyword triggers the deployment pattern (contribution: 0.8), but the staging environment hint keeps the risk in MEDIUM range. A simple confirmation is required.

Scenario 3: Production Deployment (CRITICAL — multi-party)

The same deploy function name, but with the production: True hint, triggers the production multiplier (1.6x). The combined score crosses into CRITICAL, requiring dual approval from the SRE lead and release manager. Approver 1 (sre.lead@company.com) — TEACH-BACK:
Deploying api-gateway v2.1.0 to production with a 10% canary rollout under change ticket CHG-2026-0042. This will update 1 of 10 instances initially. Approved (48.2s)
Approver 2 (release.mgr@company.com) — QUIZ:
Q1: Which service is being deployed? api-gateway Q2: What is the change ticket? CHG-2026-0042 Approved (35.4s)
Result: APPROVED (2/2 approvers, total 83.6s)

Scenario 4: Database Migration (CRITICAL — multi-party)

The run_migration function is overridden to CRITICAL risk. A custom domain’s schema migration escalation rule can require DBA and backend lead approval. Approver 1 (dba@company.com) — TEACH-BACK:
Running migration 20260213_add_user_preferences.sql on the primary production database. This will alter the users and orders tables to add preference columns. Approved (55.1s)
Approver 2 (backend.lead@company.com) — QUIZ:
Q1: Which database is affected? primary Q2: Is this migration reversible? No (DDL) Approved (41.3s)
Result: APPROVED (2/2 approvers, total 96.4s)

Scenario 5: Emergency Rollback (HIGH — quiz)

Rollbacks are emergency operations. Despite the urgency, Attesta requires a quiz challenge to verify the operator understands the rollback impact. The 15-second minimum review prevents panic-driven approvals.
Q1: Which version will the service revert to? 2.0.3 — Correct Q2: What is the reported issue? 502 errors on the checkout endpoint — Correct Q3: How many production instances will be reverted? All 10 — Correct
Result: APPROVED (reviewed in 23.7s)
Rollback protection is deliberate. During incidents, the instinct is to approve everything instantly. Attesta’s minimum review time (15s for HIGH) prevents this while keeping the delay short enough for genuine emergencies. If you need faster rollbacks, lower the high review time — but never remove it entirely.

Scenario 6: Firewall Rule Change (HIGH — teach-back)

Firewall changes trigger the custom domain’s firewall modification escalation rule, requiring teach-back verification. The security engineer and network admin are notified.
Explain what this firewall change will do: This will allow inbound TCP traffic on port 443 from the 10.0.0.0/8 CIDR range (internal network) through firewall rule FW-PROD-001. This opens HTTPS access from internal services to the production environment. Key terms matched: allow, TCP, 443, 10.0.0.0/8, ingress
Result: APPROVED (reviewed in 34.8s)

Audit Trail

After running the scenarios, the audit log at .attesta/infra-audit.jsonl contains entries for every operation:
Verify and query the infrastructure audit trail:

Risk Level Summary

A custom infrastructure domain profile can assign lower risk to canary and blue-green deployments (contribution: 0.5) compared to full rollouts (contribution: 0.8). If you primarily use canary deployments, you may find that production deploys land in HIGH rather than CRITICAL. Adjust the production amplifier boost if you want all production deploys to require multi-party approval regardless of strategy.

Compliance Mapping


Next Steps

Custom Domain Profiles

Build your own domain-specific risk profiles

Multi-Framework

Same config across LangChain, OpenAI, and Claude

LangChain Integration

Full LangChain and LangGraph reference