Skip to main content

Audit Log

Rafter writes a security audit log to ~/.rafter/audit.jsonl in JSONL format (newline-delimited JSON). Every security-relevant action — policy enforcement decisions, secret detections, overrides — is recorded as a single JSON object per line. Both the Node and Python CLIs write to the same file using the same schema. The Node CLI is the reference implementation; the Python CLI currently emits command_intercepted and secret_detected events only.

File Location

The directory ~/.rafter/ is created automatically on first use.

Schema

Every audit log entry contains these fields:

Base Fields

action Object

Present on most events. Contains context about what triggered the event.

securityCheck Object

Always present. Records the outcome of the security evaluation.

resolution Object

Always present. Records what action was taken.

Event Types

command_intercepted

Emitted when a shell command is evaluated against the security policy. Example:

secret_detected

Emitted when a secret is found in files, staged content, or tool output. The audit log never contains the raw secret value—only the type (e.g., “AWS Access Key”) and location (e.g., “staged files”, “config.js”). Example:

content_sanitized

Emitted when sensitive patterns are redacted from output. Example:

policy_override

Emitted when a user explicitly overrides a security policy (e.g., --force flag).

scan_executed

Reserved for future use. Will be emitted when file scans are performed.

config_changed

Reserved for future use. Will be emitted when security configuration is modified.

Redaction Behavior

The audit log is designed to be safe to retain and share:
  • Secret values are never logged. secret_detected events record the secret type and file location, not the secret itself.
  • Content is not stored. content_sanitized events record pattern counts and content types, not the raw content.
  • Commands are logged verbatim. command_intercepted (policy enforcement) events include the full command string. If commands contain sensitive arguments, they appear in the log.

Size and Rotation

  • No automatic rotation. The log file grows unbounded until cleanup runs.
  • Time-based retention: Entries older than retentionDays are purged when cleanup() is called.
  • No automatic scheduling. Cleanup must be triggered manually or via the API.
  • Default retention: 30 days.

Configuration

Configure audit logging in ~/.rafter/config.json under agent.audit, or in .rafter.yml under audit: Config file example:
Policy file example (.rafter.yml):

Webhook Notifications

When configured, the audit logger sends a POST request to a webhook URL for events at or above a minimum risk level. Works with Slack incoming webhooks, Discord webhooks, and generic HTTP endpoints.

Configuration

Webhook Payload

The text field provides Slack compatibility. The content field provides Discord compatibility. Both contain a human-readable summary. Webhook delivery is fire-and-forget with a 5-second timeout. Failures are silently ignored to avoid disrupting audit logging.

Setup


Querying the Audit Log

Use rafter agent audit to view and filter entries:
Or query the JSONL file directly with standard tools:

MCP Access

The read_audit_log MCP tool exposes audit log entries to MCP clients:
See MCP Integration for setup.