Developer documentation

CAIN Trace

Last reviewed 31 August 2026

QuickstartCLI referencePython SDKTypeScript SDKMCPIntegrationsPoliciesActionProofEvidenceCAIN TraceConformanceTroubleshootingDeveloper portalMarketplaceFree tierBenchmarksArchitectureCAIN IdentityCAIN ControlCAIN BudgetCAIN GovernanceCAIN MemorySelf-Hosted MCPGateCAIN PrivateCAIN TrajectoryCAIN Agent SecurityCAIN Drift7-Moat ArchitectureChangelog

CAIN Trace Documentation

Status: LIVE + FUNCTIONAL

Verified 2026-09-08: /fabric/traces/ returns [] (empty - no traces created yet, but endpoint exists and is tenant-scoped).

CAIN Trace is fully functional. The core trace engine, API, dashboard, and correlation with CAIN decisions are implemented and working.


What is CAIN Trace?

CAIN Trace records the complete execution lifecycle of every CAIN-protected action. It provides immutable, tenant-isolated execution history that correlates identity, decisions, enforcement, and evidence.

Core principle: Every CAIN decision creates a trace automatically. No manual trace creation required for normal operation.


Trace Lifecycle

A trace progresses through these stages:

1. TRACE CREATED - Action received, trace initialized

2. IDENTITY RESOLVED - Principal authenticated (if identity_id provided)

3. POLICY EVALUATED - OPA policy checked

4. AUTHORIZATION EVALUATED - Agent permissions verified

5. RISK EVALUATED - Risk score calculated

6. TRAJECTORY EVALUATED - Trajectory safety checked (if applicable)

7. CAIN DECISION - Final verdict determined

8. ENFORCEMENT APPLIED - ALLOW or DENY enforced

9. EXECUTION - Tool/MCP call made (ALLOW only)

10. EVIDENCE CREATED - Immutable record stored

11. TRACE CLOSED - Final state recorded


Data Model

ExecutionTrace

FieldTypeDescription
trace_idstringUnique trace identifier (trc_xxxx)
tenant_idstringTenant namespace
agent_idstringAgent that executed
identity_idstringIdentity of caller
actionstringAction performed
toolstringTool used
resourcestringResource accessed
decision_idstringCAIN decision ID
trajectory_idstringTrajectory ID (if applicable)
evidence_idstringEvidence record ID
verdictenumALLOW, DENY, REQUIRE_APPROVAL, UNKNOWN, ERROR
statusenumPENDING, COMPLETED, DENIED, FAILED, ERROR
execution_outcomestringWhat happened
timestamp_startdatetimeWhen trace started
timestamp_enddatetimeWhen trace ended
duration_msfloatExecution duration

TraceEvent

FieldTypeDescription
event_idstringUnique event ID
trace_idstringParent trace
event_typestringType of event
stagestringLifecycle stage
verdictstringStage verdict
detaildictEvent data
timestampdatetimeWhen event occurred

API Endpoints

Health Check

GET /fabric/traces/health

Returns trace service health status.

Create Trace (Internal)

Traces are created automatically by make_cain_decision(). Manual creation via:

POST /fabric/traces/?action=<action>&tool=<tool>

List Traces

GET /fabric/traces/

Query parameters:

Get Trace

GET /fabric/traces/{trace_id}

Returns full trace with events and integrity verification.

Get Trace Events

GET /fabric/traces/{trace_id}/events

Returns ordered list of lifecycle events.

Get Trace Evidence

GET /fabric/traces/{trace_id}/evidence

Returns evidence records with integrity verification.

Search Traces

POST /fabric/traces/search

Advanced search with multiple filters.

Stats Summary

GET /fabric/traces/stats/summary

Returns aggregate statistics.


Authentication

All trace endpoints require:

Note: Traces are automatically created when make_cain_decision() is called. The tenant is derived from the API key.


Tenant Isolation


Correlation

Decision Correlation

Every trace links to its CAIN decision via decision_id.

Evidence Correlation

ALLOW decisions create evidence linked via evidence_id.

Trajectory Correlation

When identity_id is provided, traces link to trajectories via trajectory_id.


Dashboard

Access the trace dashboard at:

https://cainstudio.online/trace
https://cainstudio.online/trace/dashboard

The dashboard displays real traces from the backend with filtering and search capabilities.


CLI

Trace commands are available via the CAIN CLI:

cain trace list
cain trace get <trace_id>
cain trace events <trace_id>

Trace States

StatusMeaning
PENDINGTrace created, decision pending
COMPLETEDAction allowed and executed
DENIEDAction blocked by CAIN
FAILEDExecution failed
ERRORSystem error (fail-closed)

Verdict Definitions

VerdictMeaningExecution
ALLOWAction permittedYes
DENYAction blockedNo
REQUIRE_APPROVALHuman approval neededNo
UNKNOWNCannot determineNo (fail-closed)
ERRORSystem failureNo (fail-closed)

Real Examples

ALLOW Trace

{
  "trace_id": "trc_abc123",
  "tenant_id": "tenant-xyz",
  "action": "deploy_service",
  "tool": "kubectl",
  "verdict": "allow",
  "status": "completed",
  "decision_id": "cain:def456",
  "evidence_id": "ev_789",
  "execution_outcome": "Service deployed successfully"
}

DENY Trace

{
  "trace_id": "trc_xyz789",
  "tenant_id": "tenant-xyz",
  "action": "delete_all_data",
  "tool": "database",
  "verdict": "deny",
  "status": "denied",
  "decision_id": "cain:ghi101",
  "execution_outcome": "Tool 'delete_all_data' is not registered for this agent"
}

Security Considerations


Limitations