Skip to content

Investigate

Recall

The local history of every command: what ran, what it executed, and what it printed.

Recall records each sqb invocation in a local SQLite store (logs/recall.sqlite3), or in a shared ClickHouse store, so you can inspect what ran, how it ended, which SQL statements executed, which audits flagged rows, and what was printed. Recall is enabled by default with no setup.

Suppose daily_revenue has a warning-level audit revenue_is_non_negative. A negative refund lands in production, unit tests still pass on mocked data, and the scheduled build exits 0 with a warning.

Check when the audit started warning:

sqb recall query \
"SELECT a.invocation_started_at AS run, a.outcome, a.violation_count, i.status, i.exit_code
FROM audit_results a JOIN invocations i USING (invocation_id)
WHERE a.audit_name = 'revenue_is_non_negative' ORDER BY run DESC LIMIT 3"
┌─────────────────────────────┬─────────┬─────────────────┬───────────┬───────────┐
│ run │ outcome │ violation_count │ status │ exit_code │
│ text │ text │ integer │ text │ integer │
├─────────────────────────────┼─────────┼─────────────────┼───────────┼───────────┤
│ 2026-10-20T00:01:44.784683Z │ warn │ 1 │ completed │ 0 │
│ 2026-10-20T00:00:34.652468Z │ pass │ 0 │ completed │ 0 │
│ 2026-10-19T23:59:23.827831Z │ pass │ 0 │ completed │ 0 │
└─────────────────────────────┴─────────┴─────────────────┴───────────┴───────────┘
3 rows

Inspect the flagged rows captured as audit evidence:

sqb recall query \
"SELECT r.text FROM audit_results a JOIN artifacts r
ON r.invocation_id = a.invocation_id AND r.digest = 'sha256:' || a.sample_digest
WHERE a.audit_name = 'revenue_is_non_negative' AND a.outcome <> 'pass'
ORDER BY a.invocation_started_at DESC LIMIT 1"

Read what that build printed:

sqb recall output last --tail 5
daily_revenue
audit revenue_is_non_negative returned 1 row
Checks PASS=81 WARN=1 FAIL=0 INSUFFICIENT=0 TOTAL=82
✓ Completed with warnings PASS=17 WARN=0 FAIL=0 SKIP=0 TOTAL=17 (3.08s)

Verify the current state in the warehouse:

sqb recall query --backend warehouse \
"SELECT payment_id, order_id, amount_cents, paid_at FROM prod.stg_payments WHERE amount_cents < 0"

Every sqb recall query accepts --json, so coding agents can follow the same workflow.

For each recorded invocation, Recall captures:

  • Invocation metadata: command, target, adapter, status, exit code, timing, error summary (error_type, error_code, error_message), cost attribution status (cost_status), selectors (selection, selector_files, selection_count, capped at 64 KiB with selection_truncated), and origin / Git revision.
  • Lifecycle and SQL: lifecycle events, every executed SQL statement (deduplicated in artifacts), and audit outcomes with audit evidence.
  • Output and diagnostics: stdout and stderr byte-for-byte up to max_output_bytes, plus framework diagnostics at or above diagnostics_min_severity. Compute logs under logs/<date>/<invocation_id>/ store the same output streams locally.

Recall writes asynchronously and never fails a command. If recording fails or drops data, the command prints a warning to stderr and still exits with its own status.

sqb recall itself, project-creation commands (sqb init), raw-query sqb diff, and instant local metadata/cache-hit commands are not recorded.

Add logs/ to .gitignore: logs/recall.sqlite3 can contain SQL, output, and warehouse rows from audit evidence.

invocations.status records one of:

Status Meaning
completed Exited 0
failed Exited with an error
cancelled Stopped by SIGTERM (signal_number = 15, exit 143) or Ctrl-C (signal_number = 2, exit 130)
running Still active (recent heartbeat)
abandoned Heartbeats stopped without a terminal event (for example SIGKILL or OOM); ended_at is the last heartbeat (ended_at_estimated = 1)
unknown Neither a terminal event nor a heartbeat was recorded

On Ctrl-C or SIGTERM, SQLBuild cancels running statements, records the end state, and exits 130 or 143. Pressing Ctrl-C or sending SIGTERM a second time exits immediately, which may leave the run abandoned.

When an audit warns or fails, Recall stores up to evidence_limit of the flagged rows (audit evidence) in artifacts keyed by sample_digest:

SELECT r.text FROM audit_results a JOIN artifacts r
ON r.invocation_id = a.invocation_id AND r.digest = 'sha256:' || a.sample_digest
WHERE a.outcome <> 'pass'

Because evidence contains warehouse values, control what is stored with audit_evidence:

Value Keeps evidence for
warn-and-error (default) Audits that warn or fail
error Audits that fail at error severity only
off No audits (sample_digest is NULL)

Recall reads HEAD from the enclosing Git repository (including worktrees and submodules). In deployments without .git, pass the commit via environment variables so production runs remain comparable:

export SQLBUILD_GIT_REVISION="$(git rev-parse HEAD)" # recorded as git_revision
export SQLBUILD_GIT_DIRTY=false # optional: recorded as git_dirty

SQLBUILD_GIT_REVISION takes precedence over .git.

Because every command targeting a warehouse writes to that target’s Recall store, invocations record where they came from so local checks stay distinct from scheduled production builds:

  • origin: orchestrated (SQLBuild server), integration (such as Dagster), ci (detected from standard CI environment variables), or local.
  • command_mode: For diagnostic commands such as sqb debug, distinguishes config_only (--no-connection) from config_and_connection without storing raw CLI arguments that could carry secrets.
  • external_context: Integration metadata JSON. The invocations view exposes integration, integration_job, integration_run_id, and integration_retry; additional fields (such as Dagster step_key/partition_key or server group_name) are queryable via JSON functions.

Configure Recall under [recall] in sqlbuild_project.toml, or override per target under [targets.<name>.recall]:

[recall]
retention = "30d"
shutdown_timeout = "3s"
diagnostics_min_severity = "info"
max_output_bytes = 2097152
audit_evidence = "warn-and-error"
[targets.ci.recall]
enabled = false
Key Default Description
enabled true Set false to disable recording
write_connection (none) sqlite or clickhouse connection for writing history (requires read_connection). Defaults to logs/recall.sqlite3
read_connection (none) Connection read by sqb recall query, schema, and output. Set alone to read shared history while recording locally
retention "30d" History retention in days (d) or hours (h), up to 3650d
shutdown_timeout "3s" Max exit flush wait (s or ms, up to 10m)
diagnostics_min_severity "info" trace, debug, info, warning, error, or critical
max_output_bytes 2097152 Max bytes kept per stream (stdout/stderr); 0 keeps all
audit_evidence "warn-and-error" warn-and-error, error, or off

Recall keeps up to max_output_bytes of each stream (default 2 MiB locally: the first half and last half). Omitted middle bytes are recorded as a single gap (gap_reason = 'truncated', truncated_bytes, complete = 0 in output_invocations), and sqb recall output prints a marker showing how many bytes were skipped. Set max_output_bytes = 0 to keep complete output. A process that is forcefully killed keeps only the first half.

Runs executed by a SQLBuild server location are copied into that target’s Recall store so sqb recall query --target prod shows scheduled runs alongside local and CI runs.

sqb location serve copies finished runs every 5 minutes through the target’s write_connection. The writer needs SELECT and INSERT on the store: it reads which runs the store already holds before it writes the rest. Copies are idempotent and only cover runs within retention.

The server deletes a finished run’s log run_log_days after it ends (14 days by default), whether or not the store holds it. Problems in the UI warns before that happens and counts what was lost:

Problem Shows when Platform webhook event
Recall copies waiting A finished run has waited over an hour, or no copy has succeeded for an hour. Names the date the oldest waiting run is deleted, and the last error No
Recall copies near deletion The oldest waiting run is halfway to that date Once per outage, as recall_prune_soon. Runs already waiting when it fired don’t fire it again
Runs lost before Recall The server deleted runs the store didn’t hold. Counts them Once per run, as recall_run_lost

A missing grant shows as Recall copies waiting with the store’s error, for example a refused SELECT. Targets with Recall disabled copy nothing.

Local SQLite stores periodically prune invocations older than retention along with their events, output, diagnostics, and unreferenced SQL text. Running invocations are never pruned.

If the store is unwritable, the command still succeeds and prints a notice on stderr (with setup SQL when applicable). A corrupt SQLite file is moved aside and replaced with a fresh store. Only sqlite and clickhouse connections are supported for write_connection.

To filter or redact what Recall stores, write an event sink that takes RecallWriter:

from sqlbuild.recall import RecallWriter
from sqlbuild.event_sinks import CommandOutputRecord, command_output_event_sink
@command_output_event_sink
def recall_output(record: CommandOutputRecord, writer: RecallWriter) -> None:
redacted: bytes = record.data.replace(b"secret-token", b"[redacted]")
writer.publish_command_output(record.replace(data=redacted))
  • A @command_output_event_sink replacement receives exact bytes in record.data and publishes at most one modified copy via writer.publish_command_output(record.replace(...)).
  • A @lifecycle_event_sink replacement filters events matching its event_kinds/min_severity and keeps them via writer.publish_lifecycle(event).
  • At most one replacement is allowed per stream (D015 on duplicates). Replacement sinks take only the record and RecallWriter (no providers; recall_writer is a reserved provider name).
  • Records not published are counted as filtered; exceptions count as failed and never fall back to storing unfiltered data. Other sinks continue receiving every record.

Query the store with sqb recall query using read-only SELECT statements in the store’s SQL dialect. Always query the views (run sqb recall schema for full columns) rather than raw recall_* tables:

View One row per
invocations Invocation (status, exit code, timing, origin, error)
statements Executed statement (resource, kind, purpose, outcome, duration, rows)
audit_results Evaluated audit and its evidence count
events Lifecycle event
diagnostics Retained diagnostic
artifacts Captured SQL or audit evidence (digest, text)
output_invocations Output completeness and truncation summary
output_transcripts Combined, stdout, and stderr transcripts
output_tail Recent output chunk
conflicts Record written twice with conflicting content

sqb recall output accepts any unique invocation ID prefix (for example 38ecc95e). In SQL, filter by invocation_id or invocation_started_at to keep queries fast—especially on ClickHouse.

statements.outcome is completed, failed, handled (failed and recovered internally), or no_terminal (process died mid-statement). When sql_available = 0, sql_unavailable_reason is not_captured or expired_or_not_captured. Take statement timings from statements rather than pairing events rows.

These run as written on the local SQLite store and on a ClickHouse store.

The latest runs of an orchestrated job, by the job name its integration records:

sqb recall query "SELECT invocation_id, invocation_started_at, status, duration_ms,
integration_run_id, integration_retry
FROM invocations WHERE integration_job = 'orders_job'
ORDER BY invocation_started_at DESC LIMIT 5"

The latest scheduled and CI builds, leaving out local diagnostics such as sqb debug:

sqb recall query "SELECT invocation_id, invocation_started_at, command, origin, status
FROM invocations
WHERE command IN ('build', 'run', 'test', 'audit', 'seed')
AND origin IN ('orchestrated', 'integration', 'ci')
ORDER BY invocation_started_at DESC LIMIT 10"

The slowest models in a run:

sqb recall query "SELECT resource_name, resource_kind, sum(duration_ms) AS total_ms
FROM statements WHERE invocation_id = '<invocation_id>' AND purpose = 'model_build'
GROUP BY resource_name, resource_kind ORDER BY total_ms DESC LIMIT 10"

Audits that did not pass:

sqb recall query "SELECT invocation_started_at, audit_name, outcome, violation_count, execution_error
FROM audit_results WHERE outcome <> 'pass'
ORDER BY invocation_started_at DESC LIMIT 20"

What a run printed at the end:

sqb recall output <invocation_id> --tail 50

statements.query_id holds the warehouse query ID on Snowflake and ClickHouse (system.query_log) so you can inspect warehouse queueing, sizing, and spilling. On BigQuery, look up job_id in the payload of the statement_submitted row in events.