Skip to main content

Function: checkpointDdl()

checkpointDdl(tablePrefix?): string

Defined in: packages/agentos/src/orchestration/checkpoint/SqlCheckpointStore.ts:73

The store's table and its indexes under a prefix: the table <prefix> and the indexes idx_<prefix>_run, idx_<prefix>_graph and idx_<prefix>_seq. A product that runs its own migrations copies this text for the prefix it gives its store into one of them and passes ensureSchema: false. The prefix is checked before the text is built, and one that SqlCheckpointStoreOptions.tablePrefix refuses throws. checkpointDdl() gives the text for the default prefix, agentos_checkpoints.

The columns:

  • id, graph_id, run_id, node_id: the checkpoint's identifiers.
  • parent_id: the checkpoint a SqlCheckpointStore.fork was made from; NULL for a checkpoint saved.
  • created_at: the checkpoint's timestamp, in epoch milliseconds.
  • save_seq: the order of the saves, which decides between checkpoints of the same timestamp.
  • state_json: the rest of the checkpoint (state, memorySnapshot, nodeResults, visitedNodes, skippedNodes, pendingEdges) as JSON.
  • metadata_json: the stateSize and hasMemorySnapshot that SqlCheckpointStore.list returns, as JSON.

Every time is epoch milliseconds in a BIGINT. The text holds no question mark: the Postgres adapter rewrites each one to a numbered parameter. The table's and the indexes' names are quoted, here and in every statement of the store, so a prefix that is an SQL keyword (order, check) names a table; a quoted lower-case name is the same name unquoted, on SQLite and on Postgres.

Parameters​

tablePrefix?​

string

The table's name; default agentos_checkpoints.

Returns​

string

The CREATE TABLE IF NOT EXISTS and CREATE INDEX IF NOT EXISTS statements, separated by semicolons.

Throws​

When the prefix is not a lower-case letter followed by at most 52 lower-case letters, digits or underscores.