v0.1.0 - local-first

AEGIS

Autonomous Engineering & Governance Intelligence System. "AI proposes and reasons. Deterministic software controls and verifies."

Python 3.14 / FastAPI PostgreSQL / Async SQLAlchemy 2.0 React 19 / Vite / Tailwind Docker / cgroups OpenTelemetry / SSE
Download Technical Whitepaper

01 / Core Architecture & API

FastAPI App Factory & Lifespan

AEGIS utilizes a highly modular FastAPI app factory. On startup, it initializes the PostgreSQL async engine, the durable EventBus, the ResourceGovernor (for concurrency limits), and wires the MCP Gateway.

def create_app(settings: Settings | None = None) -> FastAPI:
    app = FastAPI(title="AEGIS", version="0.1.0")
    
    # Instantiate deterministic concurrency governor
    governor = ResourceGovernor(
        max_ai_calls=settings.max_concurrent_ai_calls,
        max_tool_calls=settings.max_concurrent_tool_calls
    )
    app.state.governor = governor

    # Attach durable PostgreSQL EventBus
    engine = get_async_engine(settings.database.database_url)
    app.state.event_bus = EventBus(get_async_session_factory(engine))
    return app
System Dashboard

The System Overview dashboard showing aggregate risk and real-time telemetry.

Swagger API Docs

OpenAPI documentation generated by FastAPI.

JWT Auth & RESTful Routing

The REST API is secured via JWT Bearer tokens. Passwords are hashed with bcrypt. Routers are cleanly mounted by domain (e.g., /incidents, /missions, /policies).

async def login(payload: LoginRequest, session: AsyncSession = Depends(get_db_session)):
    repo = UserRepository(session)
    user = await repo.get_by_email(payload.email)
    
    if not verify_password(payload.password, user.hashed_password):
        raise HTTPException(status_code=401, detail="Invalid credentials")
        
    token = create_access_token(subject=user.email)
    return TokenOut(access_token=token)

Real-Time Telemetry (SSE)

AEGIS avoids WebSocket complexity. It uses authenticated Server-Sent Events (SSE) to stream live mission updates and tool calls to the React frontend.

@router.get("/stream")
async def stream_updates(request: Request, current_user: User):
    event_bus = request.app.state.event_bus
    q = event_bus.attach_stream()
    return StreamingResponse(
        event_generator(request, q),
        media_type="text/event-stream"
    )
Audit Log Live

The Audit Log page actively consuming the SSE stream.

02 / Agent Roster & A2A Protocol

AEGIS utilizes an Agent-to-Agent (A2A) architecture. Every agent exposes a discoverable capability card. However, agents do not use OAuth or API keys; their identities are strictly enforced internally via deterministic boundaries and the ToolRegistry.

Agent Roster

The Agent Roster showing real-time A2A capability cards and strict "CANNOT" boundaries.

Observer

Ingests telemetry, detects anomalies.

CANNOT: write to DB or execute tools.

Investigator

Forms hypotheses, collects evidence.

CANNOT: write files or alter infra state.

Coder

Generates patches in isolated sandboxes.

CANNOT: merge without Verifier sign-off.

Verifier

Runs independent regression suites.

CANNOT: modify the patch or trust Coder's claims.

Security

Intercepts tool requests, calculates risk.

CANNOT: generate code or execute remediation.

Incident Commander

Orchestrates the mission state machine.

CANNOT: execute low-level infra tools directly.

Red Team

Probes boundaries via prompt injection.

CANNOT: bypass the actual policy engine.

Researcher

Retrieves source-backed documentation.

CANNOT: modify system state or execute code.

Tool Calls & Archival Audit

Every tool invocation is persisted in the tool_calls table. This provides a cryptographic audit trail of every argument passed and every result returned, completely decoupled from the LLM context window.

class ToolCall(UUIDPrimaryKeyMixin, TimestampMixin, Base):
    __tablename__ = "tool_calls"
    tool_name: Mapped[str] = mapped_column(String(255))
    agent_id: Mapped[uuid.UUID | None]
    mission_id: Mapped[uuid.UUID | None]
    state: Mapped[ToolCallState]
    arguments: Mapped[dict | None] = mapped_column(JSONB)
    result: Mapped[dict | None] = mapped_column(JSONB)
Tool Calls

The Tool Calls archive showing real git_status invocations.

03 / Deterministic Governance

The Policy Engine

Every action is assigned a dynamic Risk Score (0-100) based on blast radius, reversibility, and environment sensitivity. Actions categorized as DESTRUCTIVE or DEPLOY are forced to a CRITICAL score and blocked.

# Deterministic policy enforcement. LLMs cannot bypass this gate.
if action.category in (ActionCategory.DESTRUCTIVE, ActionCategory.DEPLOY):
    risk_score = max(risk_score, RiskLevel.CRITICAL)

if risk_score >= RiskLevel.HIGH:
    return PolicyDecision(
        approved=False, 
        requires_human_approval=True
    )
Policy Engine

The Policy Engine dashboard displaying risk bands and tool categories.

Replay

The Replay interface showing an immutable execution snapshot.

Mission State Machine

Missions are tightly controlled state machines enforced in application code. The LLM cannot hallucinate a state transition; the Incident Commander enforces the lifecycle programmatically.

async def plan_remediation(self, mission, mission_repo):
    # Deterministically transition to REMEDIATION_PLANNED
    return await mission_repo.update_state(
        mission.id, MissionState.REMEDIATION_PLANNED
    )

Mission Archive & Auditability

The Mission Archive provides a complete historical view of all incidents. Every mission is tracked from CREATED to RESOLVED or FAILED, ensuring zero data loss and full auditability.

Mission Archive

04 / MCP Tooling & Sandbox Execution

Model Context Protocol (MCP)

Agents never touch the infrastructure directly. They interact through an MCP Gateway that registers strict tool domains: Filesystem, Git, Docker, Database, and Testing. Tools are registered with typed Pydantic schemas.

class GitStatusArgs(BaseModel):
    repo_path: str = Field(default=".")

class GitStatusTool:
    name = "git_status"
    parameters = GitStatusArgs.model_json_schema()

    async def execute(self, arguments: dict, guard: PolicyGuard):
        params = GitStatusArgs(**arguments)
        guard.assert_allowed(self.name)
        return await run_git_status(params.repo_path)
MCP Tools
Code Diffs

05 / Advanced Engineering & Database Schema

Async SQLAlchemy 2.0 Relationships

The core operational entities (Mission, Incident, Approval, ToolCall, Agent) are stored as typed relational entities with UUID primary keys, timestamp mixins, and JSONB artifact columns for flexible investigation/remediation payloads.

class Incident(TimestampMixin, UUIDPrimaryKeyMixin, Base):
    __tablename__ = "incidents"
    title: Mapped[str] = mapped_column(String(255))
    severity: Mapped[IncidentSeverity]
    status: Mapped[IncidentStatus]
    investigation: Mapped[dict | None] = mapped_column(JSONB)
    remediation: Mapped[dict | None] = mapped_column(JSONB)

Database Memory Store

AEGIS implements a deterministic, observable memory system. Retrieval uses keyword-overlap relevance (not black-box embeddings). Every result exposes the record ID, type, relevance, source, and reason for retrieval.

class MemoryRecord:
    id: uuid.UUID
    type: MemoryType
    content: str
    source: str
    timestamp: datetime
    quarantined: bool = False  # poisoned memories excluded
Verification Suite

Independent verification suite showing passed checks.

System Health & Observability

AEGIS maintains strict system health guarantees. The frontend consumes a dedicated /health/ready endpoint which checks DB connection pools, LLM provider status, and Agent readiness before serving traffic.

System Health

06 / Chaos Engineering & Benchmarks

The Chaos Lab

The Chaos Lab allows engineers to inject synthetic faults (DB exhaustion, memory leaks, container crash loops) into a shadow environment. AEGIS must detect, investigate, and remediate autonomously without human intervention.

Chaos Lab

AEGIS BENCH Evaluation

An evaluation framework that measures autonomous performance using deterministic ground-truth metrics. It drives the same agents used in production.

Root cause selected100%
Security review passed100%
Independent verification100%
Unsafe actions0
Mean pipeline duration~0.57 ms
Benchmarks Live

07 / Full Telemetry & System Views

Incident Details

Incident Detail View

Detailed view of a critical incident, showing the investigation hypotheses and remediation plan.

Approvals Queue

Human Approval Gate

Actions requiring human authorization. Pending patches and destructive commands are held here.

Replay Events

Replay & Event Log

Complete timeline of state changes and tool calls for auditability.

Health Check

System Health

API liveliness, DB readiness, and Tool Registry status.