Skip to main content

AEGIS-CHAOS: From 'Vibe Coding' to Closed-Loop SRE

Aegis-Chaos · Post 1 of 1 · → View on GitHub

From “Vibe Coding” to Closed-Loop SRE

How zero-trust policies, Git isolation, and math-based budget guardrails let an autonomous agent say “no” — and mean it.

Aegis-Chaos Dashboard Banner
Aegis-Chaos: An autonomous SRE control plane with real-time zero-trust guardrails.

Most AI coding assistants today operate on trust. You prompt, they generate, and you ship. That works—until it doesn’t. A single destructive command, an uncaught runaway loop, or a stale approval can turn an autonomous agent into a production incident.

Project Aegis-Chaos was built to answer a simple question: what happens when the AI says “no”?

This post walks through the zero-trust architecture, parallel isolation strategy, math-based budget guardrails, and end-to-end visual verification pipeline that make up our closed-loop SRE control plane—designed for the Google Developer Expert Sprint and built on the Antigravity SDK.

The Declarative Safety Stack Every tool call fans out through four policy layers before touching the shell. Tool Callrun_command L1 workspace_onlyfilesystem boundary L1 deny rm -rf /hard-coded block L2 ask_userevaluate_remediation_risk CheckpointRequestedFirestore escrow L6 allow *diagnostics pass Executeshell / cloud API L1 explicit deny L2 escrow gate L6 allow Design rule: the agent never reaches the shell without passing the stack.
Four layers. One direction. The stack is deny-by-default: nothing passes unless a layer explicitly allows it.

The Risk Predicate

The evaluate_remediation_risk predicate inspects the CommandLine string for destructive tokens or production environment references. A single match escalates the call to the L2 escrow gate:

  • Destructive: rm -rf, iptables, gcloud beta, kubectl delete, terraform destroy, pulumi destroy, drop database
  • Production: prod, production, live-cluster

Parallel Performance & Context Management

Autonomous remediation often requires multiple specialized subagents: one for infrastructure, one for UI validation, one for test coverage. Aegis-Chaos avoids context-window bloat by enforcing isolation at the Git level.

The .agents/skills/chaos-heal/SKILL.md playbook mandates plan-first discipline, an isolated Git worktree, parallel subagents scoped to that worktree, and a validation gate before any merge:

git worktree add ../remediation-worktree -b hotfix/remediate-latency

By scoping each subagent to a single worktree, we reduce prompt size, lower Tinput / Toutput / Tthoughts per turn, and enable parallel execution without competing for the same context window.

The Non-Blocking Checkpoint State Machine

Long-running remediation loops risk infinite retries or runaway token spend. Aegis-Chaos enforces a hard budget constraint in real time.

Cturn = κ · (Tinput + Toutput + Tthoughts) + Σ Ψtoolj
Symbol Meaning Default
κ (kappa)Cost per token0.0001
TinputPrompt tokens consumed
ToutputCompletion tokens generated
TthoughtsInternal reasoning tokens
Ψ (psi)Cost per tool call0.01
MTools invoked this turn
Ccumulative = Σ Cturnt ≤ Θbudget

If Ccumulative exceeds Θbudget (default 2.0), the TokenLedger trips a kill_switch. The conversation loop halts immediately.

At-Most-Once Execution via Firestore Delete-First

When a checkpoint is requested, the system must guarantee that the remediation session resumes exactly once, even under Cloud Tasks delivery retries.

resume_from_checkpoint enforces this by reading the Firestore checkpoint document, deleting it first — before any Git checkout or conversation replay — and then verifying the deletion succeeded by re-reading the document. Only after the delete is confirmed does the worker restore the Git worktree and resume the Antigravity conversation thread.

If the task retries, the document is already gone, so the worker returns False and the session scales down cleanly.

End-to-End Verification Flow

Visual regressions are first-class bugs. Aegis-Chaos ships an automated browser-actuation pipeline to catch them.

4.1 Performance Dashboard

The control plane interacts with a live dashboard exposing a latency metrics card with a Run Latency Probe button. Calling GET /latency?hotfix=enabled returns 45ms optimized; otherwise 2500ms degraded. The frontend toggles the card between .card.degraded (red #e74c3c) and .card.optimized (green #2ecc71).

4.2 Browser Actuation Script

.agents/skills/chaos-heal/scripts/verify_ui.py drives a headless Chrome debugging session, clicks #probe, reads getComputedStyle(el).borderTopColor, and compares it against design tokens. A screenshot is saved to artifacts/web_ui_assertion.png and a .webm recording to artifacts/validation_run.webm.

Aegis Latency UI Verification Card
The visual assertion card captured by Playwright after the latency probe runs.

Setup & Run Instructions

5.1 Prerequisites

  • Python 3.10+
  • Git
  • Docker (for GKE cluster MCP runtime)
  • Node.js / npx (for Playwright browser install, optional)

5.2 Clone and Install

git clone https://github.com/<org>/project-aegis-chaos.git
cd project-aegis-chaos
python3 -m venv venv
source venv/bin/activate
pip install -e .

5.3 Configure Antigravity CLI

Create ~/.gemini/antigravity-cli/settings.json:

{
  "toolPermission": "request-review",
  "theme": "monokai",
  "verbosity": "low",
  "title": { "enabled": true, "scripts": ["<repo>/.agents/skills/chaos-heal/scripts/render_title.sh"] },
  "statusLine": { "enabled": true, "scripts": ["<repo>/.agents/skills/chaos-heal/scripts/render_status.sh"] }
}

Create ~/.gemini/antigravity-cli/mcp_config.json:

{
  "mcpServers": {
    "gke_cluster_mcp": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "-v", "${HOME}/.config/gcloud:/root/.config/gcloud:ro",
        "-v", "${HOME}/.kube:/root/.kube:ro",
        "-e", "KUBECONFIG=/root/.kube/config",
        "gcr.io/google-containers/kubectl:latest"
      ]
    }
  }
}

5.4 Launch Services

To experience Aegis-Chaos locally, we start the API webhook ingestion gateway and the dashboard side-by-side using the local virtual environment:

Terminal 1 — Webhook Ingest Gateway (port 8000):

./venv/bin/uvicorn src.aegis_chaos.webhook_ingest:app --host 0.0.0.0 --port 8000

Terminal 2 — Performance Dashboard (port 8080):

./venv/bin/python tests/mock_services/app.py

5.5 Run Offline Verification Suite

You can run our unit test harness validating the security fabric constraints, HMAC headers, timestamp skewing, and check pointing logic locally:

./venv/bin/pytest -q

Expected output: 8 passed in 0.02s

5.6 Run Automated Visual Verification

Playwright can actuate Chrome in headless mode to simulate visual regressions on the UI dashboard card (clicking the probe and capturing design tokens):

# Ensure Playwright browser binaries are present
./venv/bin/playwright install chromium

# Execute the UI validation script
./venv/bin/python .agents/skills/chaos-heal/scripts/verify_ui.py

This outputs RECORDING: artifacts/validation_run.webm and writes a visual PNG trace inside the artifacts/ directory.

5.7 Execute Autonomous Self-Healing Pipeline

To run the agent-driven orchestrator, load the safety policies and initiate the Antigravity session runner with a simple Python script:

import asyncio
from aegis_chaos.orchestrator import run_healing_pipeline

# Starts the stateful healing agent within your workspace
asyncio.run(run_healing_pipeline("/workspace/root"))

5.8 Direct Pipeline Execution

To run the entire pipeline end-to-end locally, configure the active environment variables and execute the local integration test:

# Configure active dev mode and webhook secret
export AEGIS_LOCAL_MODE=true
export AEGIS_WEBHOOK_SECRET=aegis-secret-key

# Execute the local E2E test
./venv/bin/python tests/test_local_e2e.py

This runs uvicorn in the background, triggers a real HTTP post to /webhooks/alert, validates the HMAC-SHA256 signature, dispatches to the task handler, checks out the git worktree, and verifies checkpoint deletion.

Security & Compliance Summary

Threat Vector Mitigation
Tampered webhook payloadHMAC-SHA256 with hmac.compare_digest
Replay attackMillisecond timestamp ±60s drift window
Runaway agent loopToken budget kill-switch (Ccumulative > Θbudget)
Destructive shell commandL1 explicit deny + L2 escrow checkpoint
Partial failure / retryFirestore delete() before side effects
Context pollutionGit worktree isolation + scoped subagent contexts

Lifecycle at a Glance

Closed-Loop SRE Lifecycle From anomaly detection to evidence-based reporting, every step is policy-gated and budget-bounded. Anomaly Detectedingress latency spike Webhook HMAC + Timestampreplay guard + signature Cloud Tasks Enqueuerun-{session_id} dedup Worker: Delete-FirstFirestore checkpoint Restore Git Worktreehotfix/remediate-latency Resume Agent Conversationconversation_id replay L1 workspace_onlyboundary L1 deny rm -rf /hard block L2 ask_userevaluate_remediation_risk CheckpointRequestedFirestore escrow L6 allow *diagnostics pass Token Ledger + Kill-SwitchC_cumulative ≤ Θ_budget L1 explicit deny / checkpoint path L2 escrow gate L6 allow / safe path Design rule: every path is logged, budgeted, and either approved or explicitly denied.
From anomaly to evidence: every arrow is a decision point, every box is a safety boundary.

Lifecycle at a Glance

The full closed-loop flow, in plain text:

Anomaly Detected
      │
      ▼
Webhook HMAC + Timestamp Guard
      │
      ▼
Cloud Tasks Enqueue run-{session_id}
      │
      ▼
Worker: Firestore delete-first checkpoint
      │
      ▼
Restore isolated Git worktree
      │
      ▼
Resume Antigravity agent conversation
      │
      ▼
   ┌──┴──┐
   │     │
L1 Deny  L2 Ask User
   │     │
   │     ▼
   │  CheckpointRequested → Firestore
   │     │
   │     ▼
   │  Out-of-band approval
   │     │
   └──┬──┘
       │
       ▼
   L6 Allow diagnostic
       │
       ▼
Token Ledger: C_turn, C_cumulative
       │
   ┌───┴───┐
   │       │
Budget OK  Budget Breached
   │       │
   │       ▼
   │   Kill-switch → scale down
   │       │
   └───┬───┘
       │
       ▼
Browser actuation: verify UI + record WebM
       │
       ▼
Report evidence + leave branch for review

Project Aegis-Chaos · autonomous self-healing SRE control plane built for the Google Developer Expert Sprint. Code: github.com/rabimba/aegis.

Comments

Popular posts from this blog

Racecraft (Project Koru) · Prologue — The Origin Story

Racecraft · Prologue , The Origin Story It Started With a Wine List and a Question About Racing How a happy-hour conversation in the Bay Area turned into a trustable AI race coach , and then into a second version that runs entirely on a phone, on the NPU. This is the prologue to a five-part series. Two years ago(1st November, 2024) I was in the Bay Area for a GDE Summit. If you've never been: it's a couple of days of talks among Google Developer Experts, the kind of people who get unreasonably excited about a new on-device runtime, and then , mercifully , a happy hour where everyone stops performing and just eats. We ended up at a restaurant(Puesto Santa Clara), a long table of GDEs, and I was doing the most important engineering of the evening: trying to decide which wine to order. Across the table was Ajeet Mirwani . I don't even remember how the wine talk turned into racing talk , these things drift , but the moment the word "racing" ...

A Split‑Brain Neuro‑Symbolic Training Method for High‑Velocity Autonomous Coaching from Telemetry

 Author: Rabimba Karanjai Scope: Problem statement + data methodology + model training (no deployment discussion) Abstract Real‑time coaching in motorsport is a safety‑critical learning problem : a system must map noisy, high‑frequency telemetry to short, actionable guidance that remains physically consistent and avoids hazardous recommendations . This paper proposes a “Split‑Brain” training formulation that separates (i) a semantic coaching target (what action/critique should be expressed) from (ii) a reflexive interface (how actions are represented as compact, verifiable tokens). The approach trains a Small Language Model (SLM) in the Gemma family [1] using QLoRA fine‑tuning [2] , and introduces a telemetry tokenizer plus teacher‑student synthesis pipeline to generate instruction‑action pairs at scale. Core contribution: a reproducible method to convert “ golden lap ” differential tel...

My Friend's MRI Didn't Come with a Manual, So I Built One with AI

Gemma 4 Good Hackathon · Impact Track · Health & Sciences It started with two envelopes. One contained a single sheet of paper, a radiologist's report for my friend. It was a wall of text that might as well have been written in another language. Words like " parenchymal volume ," " hyperintensities ," and " susceptibility artifact " stared back at us, creating more anxiety than they resolved. The other was a flimsy paper sleeve containing a CD-ROM. This, we were told, held the actual images from her MRI scan. The ground truth. And we couldn't even look at it. Our laptops, like most these days, don't have disc drives. For a moment, this crucial, deeply personal piece of her health information was a coaster. I felt that familiar, hot-wired frustration every engineer knows: the feeling of being locked out by a dumb problem. The powerlessness was infuriating. So, I did what any slightly obsessive software engineer would do...