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.
An investigation, start to finish
Section titled “An investigation, start to finish”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 rowsInspect 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.
What is recorded
Section titled “What is recorded”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 withselection_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 abovediagnostics_min_severity. Compute logs underlogs/<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.
How a run ended
Section titled “How a run ended”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.
Audit evidence
Section titled “Audit evidence”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_digestWHERE 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) |
Git revision
Section titled “Git revision”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_revisionexport SQLBUILD_GIT_DIRTY=false # optional: recorded as git_dirtySQLBUILD_GIT_REVISION takes precedence over .git.
Where a run came from
Section titled “Where a run came from”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), orlocal.command_mode: For diagnostic commands such assqb debug, distinguishesconfig_only(--no-connection) fromconfig_and_connectionwithout storing raw CLI arguments that could carry secrets.external_context: Integration metadata JSON. Theinvocationsview exposesintegration,integration_job,integration_run_id, andintegration_retry; additional fields (such as Dagsterstep_key/partition_keyor servergroup_name) are queryable via JSON functions.
Settings
Section titled “Settings”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 = 2097152audit_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 |
Output limit
Section titled “Output limit”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.
Server runs
Section titled “Server runs”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.
Retention
Section titled “Retention”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.
Filtering what Recall stores
Section titled “Filtering what Recall stores”To filter or redact what Recall stores, write an
event sink that takes RecallWriter:
from sqlbuild.recall import RecallWriterfrom sqlbuild.event_sinks import CommandOutputRecord, command_output_event_sink
@command_output_event_sinkdef 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_sinkreplacement receives exact bytes inrecord.dataand publishes at most one modified copy viawriter.publish_command_output(record.replace(...)). - A
@lifecycle_event_sinkreplacement filters events matching itsevent_kinds/min_severityand keeps them viawriter.publish_lifecycle(event). - At most one replacement is allowed per stream (
D015on duplicates). Replacement sinks take only the record andRecallWriter(no providers;recall_writeris a reserved provider name). - Records not published are counted as
filtered; exceptions count asfailedand never fall back to storing unfiltered data. Other sinks continue receiving every record.
Querying history
Section titled “Querying history”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.
Common questions
Section titled “Common questions”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 50From a statement to the warehouse
Section titled “From a statement to the warehouse”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.