CSVExporter for spreadsheet-compatible output and JSONExporter for structured data interchange. Both implement the AuditExporter protocol and can be used interchangeably.
AuditExporter Protocol
The base protocol that all exporters implement.Import
Signature
| Parameter | Type | Description |
|---|---|---|
entries | list[AuditEntry] | List of audit entries to export. |
output | IO[str] | A writable file-like object (e.g., open() result, StringIO). |
CSVExporter
Export audit entries as CSV. Nested dict fields (likemetadata) are JSON-serialized.
Import
Constructor
| Parameter | Type | Default | Description |
|---|---|---|---|
columns | list[str] | None | None | List of field names to include as columns. Defaults to DEFAULT_COLUMNS. |
Default Columns
When no custom columns are provided, the following fields are exported:| Column | Description |
|---|---|
entry_id | Unique identifier for the audit entry. |
intercepted_at | Timestamp when the action was intercepted. |
action_name | Name of the gated function. |
risk_score | Numeric risk score (0.0 - 1.0). |
risk_level | Discrete risk level (low, medium, high, critical). |
challenge_type | Type of challenge presented. |
verdict | Approval outcome (approved, denied, etc.). |
agent_id | Identifier of the AI agent. |
review_duration_seconds | Time the operator spent reviewing. |
chain_hash | SHA-256 hash for tamper detection. |
Example
JSONExporter
Export audit entries as a JSON array. Supports pretty-printing with configurable indentation.Import
Constructor
| Parameter | Type | Default | Description |
|---|---|---|---|
indent | int | None | 2 | Number of spaces for pretty-printing. None for compact single-line output. |
Example
Custom Exporters
You can implement theAuditExporter protocol to create custom exporters:
Audit Trail
How audit entries are created and stored
CLI Audit
Export and verify audit logs from the command line