# Audit log

Every tool call is written to the `calls` table of the Godelgate SQLite database (`GODELGATE_DB`, default `data/godelgate.db`) before anything else happens, then updated when it finishes.

## What's recorded

| Column | Description |
| --- | --- |
| `id` | Call ID (also the approval ID) |
| `ts` | When the call arrived, in milliseconds since the Unix epoch |
| `user` | User name from the key |
| `session` | MCP session ID |
| `tool` | Namespaced tool name |
| `args` | Arguments, redacted (see below) |
| `labels` | The tool's trifecta labels |
| `decision` | `allow`, `deny` or `approve` |
| `reason` | Why: the rule, the trifecta explanation, quarantine or `default policy` |
| `status` | See [Call statuses](/docs/dashboard#call-statuses) |
| `duration_ms` | Time spent in the upstream call |
| `result` | The tool's result, redacted, or the error message |
| `approved_by` | Who approved or rejected, or `timeout` |

## Redaction

Arguments and results are stored redacted, so the log is useful for investigations without becoming a second copy of your data:

- Values under keys that look like secrets (`password`, `secret`, `token`, `api_key`, `auth`, `credential`, case-insensitive) become `[redacted]`.
- Strings longer than 400 characters are cut, with their original length noted.
- Arrays keep their first 50 items, and nesting stops at 6 levels.

## Querying

The database is a plain SQLite file. For example, everything the trifecta blocked in the last day:

```bash
sqlite3 /data/godelgate.db "
  SELECT datetime(ts / 1000, 'unixepoch'), user, tool, reason
  FROM calls
  WHERE status = 'denied' AND reason LIKE 'lethal trifecta%'
    AND ts > (strftime('%s', 'now') - 86400) * 1000
  ORDER BY ts DESC;"
```

Every call by one user, newest first:

```bash
sqlite3 /data/godelgate.db "SELECT * FROM calls WHERE user = 'alice' ORDER BY ts DESC LIMIT 50;"
```

## Live stream

The admin event stream sends each call as it's recorded and updated. See [HTTP API](/docs/http-api#live-events).

## Retention

Godelgate never deletes audit rows. Back up the database file, and prune old rows with SQL if you need to.
