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, and both emit four event types: command_intercepted, secret_detected, content_sanitized, and scan_executed. config_changed and policy_override remain reserved in both runtimes, as noted below.
Each one-shot
rafter secrets scan writes one scan_executed entry with counts and pattern names, never a matched value. See Secret Scanning for which paths log secret_detected (watch mode and the hook).File Location
~/.rafter/ is created automatically on first use, mode 0700; each append to audit.jsonl is written mode 0600. A failed write (disk full, permissions) is reported once on stderr and never changes the security decision it was logging.
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 (field order as Node actually writes it —
cwd/gitRepo/prevHash/timestamp/sessionId come after resolution, not before eventType):
eventType and the event-specific objects — and includes an explicit null for an absent optional field (gitRepo, agentType) where Node omits the key entirely:
secret_detected
Emitted when a secret is found by rafter secrets --watch, or by the PreToolUse hook intercepting a file write or a staged commit. A one-shot rafter secrets scan emits scan_executed instead.
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
Reserved; an approval at the prompt is logged as command_intercepted with actionTaken: "overridden".
scan_executed
Emitted once per one-shot rafter secrets scan (any format, including --json and --format sarif), whether or not it finds anything. It records counts and pattern names only, never a matched value, redacted or otherwise.
Suppressed findings (baseline or
.rafter.yml ignore:) are not counted.
Example:
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_detectedevents record the secret type and file location, not the secret itself. - Content is not stored.
content_sanitizedevents 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 or pruning. The log file grows unbounded.
Configuration
Configure audit logging in~/.rafter/config.json under agent.audit, or in .rafter.yml under audit:
Dot-paths in this page are Node’s camelCase (
agent.audit.retentionDays, agent.notifications.minRiskLevel); Python takes the same keys in snake_case. See Configuration Keys for the casing note.
Config file example:
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
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
Userafter agent audit to view and filter entries:
Verifying the Hash Chain
Each entry’sprevHash is the SHA-256 of the previous raw line in the file (including its trailing newline), or null for the first entry — so the lines form a hash chain, each one committing to everything before it. rafter agent audit --verify recomputes the chain and reports any break:
prevHash doesn’t match the actual hash of the line before it, --verify reports the break and exits 1:
Each entry is verified against the
prevHash recorded in the entry after it, so the newest entry is covered once a later entry is written.MCP Access
Theread_audit_log MCP tool exposes audit log entries to MCP clients:

