Reference · optional
Control plane
A self-hosted backend that collects audit records from every agent you run and makes them queryable in one place. You don't need it to use Aegis. Skip this page unless the trail spread across hosts is a problem you actually have.
What it is
For one agent on one machine, logs/audit.jsonl is enough. Across a fleet it isn't: the trail is scattered over many hosts and grep is your only query tool. The control plane is a FastAPI service over Postgres that accepts batches of audit records and answers questions like these:
- Every denied call in the last thirty days.
- Which agents have ever been allowed to write to production paths.
- Which policy version (
spec_hash) was active when a given decision was made. - The full tool-call sequence of one agent run, in order.
It is single-tenant, with one API key per deployment. There's no users table, no RBAC, no SSO and no hosted version. It lives in a separate repository and shares no code with the library. The only link between them is an HTTP POST to /v1/records.
Getting it running
It needs Docker. From a clean checkout:
git clone https://github.com/obengbuo/aegis-controlplane.git
cd aegis-controlplane
cp .env.example .env
# set POSTGRES_PASSWORD; compose refuses to start without one
docker compose up -dThis starts three services: Postgres, the API, and a read-only UI at http://localhost:8080. Migrations run automatically when the API starts. Next, create a key for a deployment:
docker compose exec api aegis-cp create-deployment --id prod-us-east
The key is printed once. Only its argon2 hash is stored. If port 8000 or 8080 is already in use, set AEGIS_CP_PORT or AEGIS_CP_UI_PORT in .env.
Pointing the library at it
You need three AegisConfig fields. They all default to None, and nothing is shipped unless control_plane_url is set.
import os from aegis import AegisConfig, propose_spec, wrap_toolset config = AegisConfig( # 1. first: this sandbox_root=sandbox, # starts the shipper control_plane_url="http://localhost:8000", control_plane_api_key=os.environ["AEGIS_CP_API_KEY"], deployment_id="prod-us-east", ) spec = propose_spec(user_request, sandbox_root=sandbox, # 2. then the spec run_id=config.run_id) wrap_toolset(fs, "filesystem", spec=spec, config=config) # 3. then the toolset
| Field | Purpose |
|---|---|
control_plane_url | Base URL. Records are POSTed to {url}/v1/records. If unset, nothing is shipped. |
control_plane_api_key | Bearer token. Read it from the environment, and never commit it. |
deployment_id | Labels this deployment's records, so one backend can serve several deployments. |
Create AegisConfig before you call load_spec or propose_spec. Creating the config is what starts the shipper. A spec_loaded record written before that point stays in JSONL only. If this happens, Aegis says so on stderr and names the affected run_id.
It is not in the enforcement path
If the control plane is unreachable, slow, misconfigured or returning errors, enforcement doesn't change. Tool calls are still evaluated, decisions are still correct, records still land in JSONL, and the run finishes normally. Failing to centralise a record is an observability problem. Failing to enforce would be a security incident, so Aegis keeps the two separate.
write_recordwrites JSONL first, then puts the record on a non-blocking in-memory queue. All network I/O runs on a background daemon thread.- There is never backpressure. If the queue fills, the oldest queued record is dropped and counted. It's dropped from the ship queue only, never from JSONL. The count goes to the backend as
dropped_since_last_batch, so a gap in the central view shows up as a gap. - A 4xx is reported once on stderr and names what to check. A temporary 5xx is retried with backoff.
- On shutdown, there's one final flush attempt, bounded by a timeout.
ALLOW honoured, result returned: 'file contents' DENY still enforced: arg 'path' value '/etc/shadow' not in capability spec JSONL still durable: ['ok', 'denied']
Query API
| Endpoint | Purpose |
|---|---|
POST /v1/records | Ingest a batch. Idempotent on call_id. |
GET /v1/records | Filtered, paginated history, newest first. |
GET /v1/runs/{run_id} | One agent run, in order. |
GET /v1/summary | Counts by status, server, tool and rule. |
GET /v1/denials | The security view. |
GET /v1/health | Liveness check. The only route that needs no authentication. |
Every read is limited to the deployment whose key made the request. Interactive API docs are served at localhost:8000/docs.
curl localhost:8000/v1/health curl -H "Authorization: Bearer $KEY" "localhost:8000/v1/denials?limit=20" curl -H "Authorization: Bearer $KEY" "localhost:8000/v1/summary"
Linked vs. inferred spec association
If you pass run_id=config.run_id to the loader, the run's opening spec_loaded record is linked to its tool calls by exact match. If you leave it out, the control plane infers the link from spec_hash and timestamp order, and the UI shows which method was used.
Retention
Records older than AEGIS_CP_RETENTION_DAYS (90 by default) are rolled up into daily_summaries, which hold counts by status, server, tool and matched rule. The originals are then deleted, in batched transactions that count and delete the same rows together. The API runs this on a timer, and you can also run it by hand:
docker compose exec api aegis-cp retention --dry-run docker compose exec api aegis-cp retention
To use an external scheduler instead, set AEGIS_CP_RETENTION_ENABLED=false.
Deliberately not built
Policy distribution, an approval queue, multi-tenancy, RBAC and SSO are not built, on purpose. The control plane observes. It doesn't decide, and that boundary is permanent.
Source of truth: README.md on GitHub. If this page and the repository disagree, the repository wins — and please open an issue.