Audit Logging
Every access is logged for compliance and provenance.
Cortex logs every read, write, and denial to an append-only audit trail. This ensures complete provenance tracking for compliance and debugging.
Audit Entry Structure
{
"id": "uuid",
"org_id": "uuid",
"actor_type": "agent",
"actor_id": "uuid",
"on_behalf_of": "uuid",
"action": "recall",
"target_id": "uuid",
"scope_key": "engineering",
"result": "allowed",
"tokens_in": 45,
"tokens_out": 320,
"created_at": "2025-01-15T10:30:00Z"
}
Fields
| Field | Description |
|---|---|
actor_type | user or agent |
actor_id | ID of the acting user or agent |
on_behalf_of | User the agent is acting for |
action | What was attempted |
target_id | Memory ID involved |
scope_key | Scope accessed |
result | allowed or denied |
tokens_in | Input tokens (for AI queries) |
tokens_out | Output tokens (for AI queries) |
Action Types
| Action | When |
|---|---|
recall | Memory search query |
remember | Memory write |
deny | Access denied (policy violation) |
redact | Memory redaction |
policy_change | Policy matrix update |
What Gets Logged
graph TB
A[Agent Request] --> B{Policy Check}
B -->|Allowed| C[Execute Operation]
B -->|Denied| D[Log Denial]
C --> E[Log Success]
E --> F[Audit Trail]
D --> F
Every operation logs:
- Who — Actor identity and the user they're acting for
- What — Action type and target memory
- Where — Scope accessed
- Result — Allowed or denied
- Tokens — Input/output token counts (for AI queries)
- When — Timestamp
Who can read the audit log
The audit trail spans every scope and actor in the org, so it is treated as
administrative governance data: only the workspace owner (CEO) can view or
export it (GET /api/audit, /api/audit/export). Lower roles receive a 403 and
the Audit Log entry is hidden from their navigation — the same owner-only gate
applied to the Policy matrix and Scopes. This prevents a lower-clearance member
from learning about activity in scopes they cannot otherwise read.
Querying Audit Logs
# List recent entries
curl -H "Authorization: Bearer crtx_..." \
https://your-cortex-host/api/audit?limit=100
# Filter by action
curl -H "Authorization: Bearer crtx_..." \
"https://your-cortex-host/api/audit?action=recall&result=denied"
Compliance Properties
| Property | Description |
|---|---|
| Append-only | Entries cannot be modified or deleted |
| Complete | Every access is logged |
| Attributed | Every entry has actor identity |
| Token-counted | AI query costs are tracked |
Audit logs are retained indefinitely for compliance. They cannot be deleted or modified.