Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SQLite Store (.azs)

All session data lives in a single file: .azureal/sessions.azs. This is a standard SQLite database using DELETE journal mode, accessible by any SQLite client. The .azs extension is intentional – it discourages users from casually browsing or editing the file, signaling that AZUREAL owns the format and schema.


Lazy Creation

The store file is not created when you open a project. It is created lazily on first use – specifically, when you create your first session. Projects that have never had a session will not have a sessions.azs file (though the .azureal/ directory may still exist for configuration files like azufig.toml).


Session Numbering

Sessions are numbered sequentially: S1, S2, S3, and so on. These are display identifiers used in the session list and status bar. The numbering is simple and monotonic – there is no reuse of session numbers after deletion.


Schema

The database contains four tables:

sessions

The primary session record.

ColumnTypeDescription
idINTEGERPrimary key, auto-incremented
nameTEXTUser-assigned session name (or default “Sn”)
worktreeTEXTPath to the git worktree this session belongs to
createdTEXTISO 8601 timestamp of session creation
completedINTEGERBoolean success flag (1 = success, 0 = failure, NULL if still active)
duration_msINTEGERTotal session duration in milliseconds
cost_usdREALAccumulated cost in USD (populated on completion)
last_claude_uuidTEXTUUID of the last Claude JSONL session file (for orphan recovery)

events

Every prompt, response, tool call, and tool result is stored as an event.

ColumnTypeDescription
idINTEGERPrimary key, auto-incremented
session_idINTEGERForeign key to sessions.id (with cascade delete)
seqINTEGERSequence number within the session (monotonically increasing)
kindTEXTEvent type (e.g., UserMessage, AssistantText, ToolCall, ToolResult, Complete)
dataTEXTZstd-compressed JSON event payload (stored as blob despite TEXT type)
char_lenINTEGERCharacter length of the original (uncompressed) event data

A unique constraint on (session_id, seq) prevents duplicate events.

compactions

Compaction summaries that replace older event ranges.

ColumnTypeDescription
idINTEGERPrimary key, auto-incremented
session_idINTEGERForeign key to sessions.id (with cascade delete)
after_seqINTEGERThe sequence number after which events were compacted
summaryTEXTThe 2000–4000 character compaction summary
createdTEXTISO 8601 timestamp of when the compaction was stored

meta

Key-value store for runtime state and schema versioning.

ColumnTypeDescription
keyTEXTMetadata key
valueTEXTMetadata value

The primary key stored here is schema_version, which tracks the database schema version for migrations. Other runtime state such as the active session ID and PID-to-session mappings are held in memory on the App struct, not persisted to the database.


Event Storage and Compaction

Events are not stored verbatim from the agent’s JSONL output. Before serialization, append_events() applies compact_event() to each event, which reduces storage size by truncating event content to match what the UI actually renders:

ToolResult Truncation

ToolTruncation Rule
ReadFirst line + last line only
BashLast 2 lines only
GrepFirst 3 lines only
GlobFile count only (individual paths discarded)
TaskFirst 5 lines only
Default (all others)First 3 lines

ToolCall Input Stripping

Tool call inputs are stripped down to their key field only. Two exceptions:

  • Edit – preserved in full, because the session pane renders diffs from the old_string and new_string fields.
  • Write – summarized rather than stored verbatim, since file contents can be arbitrarily large.

This compaction is applied at ingestion time, not at query time. The stored events are already in their compact form.


Completion Persistence

When an agent process sends a Complete event, AZUREAL calls mark_completed(session_id, duration_ms, cost_usd) on the store. This populates the completed, duration_ms, and cost_usd columns in the sessions table.

The session list in the UI reads these fields to render completion badges:

  • Green check – session completed successfully.
  • Red X – session completed with a failure status.

Sessions that have not yet completed (or are still active) show no badge.