Skip to main content

Query model reference

Every mounted Dataset is a SQL schema. A positional Dataset is named dataset; --mount NAME=DATASET creates a named schema. The schema exposes six stable relations even when no compatible Source contributes rows.

RelationOne row representsAvailable from
sourcesone discovered Source candidateevery Dataset
runsone normalized Run/sessionevery ready run data source
stepsone normalized Stepevery ready run data source
tool_callsone tool invocation and its linked resultevery ready run data source
eventsone canonical write-time factcanonical event Sources only
trajectoriesone complete Run with ordered Step and tool aggregatesnormalized run data sources

Use DESCRIBE for the exact columns exposed by the installed version:

DESCRIBE dataset.sources;
DESCRIBE dataset.runs;
DESCRIBE dataset.steps;
DESCRIBE dataset.tool_calls;
DESCRIBE dataset.events;
DESCRIBE dataset.trajectories;

Source identity

Entity IDs are Source-local. runs, steps, tool_calls, and events retain _file_, the Dataset-relative source_path. A durable entity address includes the Dataset URI, _file_, entity kind, and original ID.

When joining built-in Run relations inside one Dataset, include _file_ alongside the entity key:

SELECT r.run_id, s.step_id, s.message_kind, s.message_value
FROM dataset.runs r
JOIN dataset.steps s
ON r._file_ = s._file_
AND r.session_id = s.session_id;

A built-in join that omits _file_ is rejected because equal IDs in two Sources do not identify the same entity. Across separately named Datasets, _file_ equality is not required because each schema is already a different namespace.

sources

ColumnTypeMeaning
_file_UTF-8, non-nullDataset-relative Source path
formatUTF-8, nullabledetected or declared representation
kindUTF-8, non-nullstore or file
snapshot_refUTF-8, nullablegeneration, manifest revision, fingerprint, version, or ETag
projection_statusUTF-8, nullablefresh or stale for a canonical events Source with a linked Storyline projection
projection_generationUTF-8, nullablegeneration selected as the read acceleration projection
projection_candidatesUInt64, non-nullnumber of linked projection candidates considered
size_bytesUInt64, nullablecandidate file or marker-object size
last_modifiedUTF-8, nullableRFC 3339 timestamp when available
statusUTF-8, non-nullready or error
errorUTF-8, nullablesanitized discovery or resolution error

format may remain null until a selected peripheral file is opened lazily. Filtering _file_ can prevent unrelated Sources from being opened. snapshot_ref is a display projection; Rust/API consumers use the typed CatalogSourceRevision for consistency decisions.

Find expressions

pchronicle find --match is the current locate syntax. The installed CLI parser (FindExpr) is authoritative. RFC-0012 records the accepted decision and is not a command reference.

Plain terms search indexed Storyline Step content (FTS / Jieba). Scoped text uses #field(term):

SelectorMeaning
#contentmessage_value, observation, and prompt
#messagemessage_value
#usermessage_value where source = 'user'
#assistantmessage_value where source = 'agent' (#agent is an alias)
#systemprompt and message_value where source = 'system'
#reasoningreasoning_content
#observationobservation
#promptprompt and message_value
#modelmodel_name (#model_name is an alias)
#envenv
#allall indexed Step text columns

AND / OR / NOT and parentheses combine predicates. JSONB uses $.path OP value or #json.COLUMN("$.path") OP value, where OP is =, !=, >, >=, <, or <=. Repeat --match to AND expressions.

The current implementation infers search.scope from the expression:

Expressionsearch.scopesearch.mode
Text onlystepsfts
JSON only, no Step columnrunsjson
#json.metrics(...) onlystepsjson
Text plus JSONstepsfts+json
Identity flags onlyrunsidentity

A JSON-only expression without #json.metrics(...) searches run-level JSONB columns (agent_extra, final_metrics, extra, meta, unknown_fields). Mixed text/JSON and explicit #json.metrics(...) search step-level JSONB (metrics, extra).

Query boundary

The engine accepts one read-only SELECT, VALUES, DESCRIBE, or EXPLAIN statement. It rejects DDL, DML, COPY, mutating functions, and multiple statements. CLI row, byte, discovery, and timeout limits still apply.

Exact physical Storyline columns are documented by Storyline Lance. Discovery and predicate-pruning mechanisms belong to Snapshot design. Use the query guide for a complete workflow.