Skip to main content

Module sqlite

Module sqlite 

Source
Expand description

SqliteRunStore — SQLite-backed RunStore using [rusqlite-isle].

The Connection is confined to a dedicated OS thread by AsyncIsle; every call is a typed closure dispatched over a bounded channel. step_entries, degradations, and result_ref are stored as JSON blobs — the former two are pure trace/observability artifacts (not queried relationally), the latter is caller-defined payload shape. append_step_entry/append_degradation run as a read-modify-write inside a single transaction so concurrent appenders don’t clobber each other’s entries.

§Schema

CREATE TABLE IF NOT EXISTS runs (
  id                 TEXT PRIMARY KEY,
  task_id            TEXT NOT NULL,
  status             TEXT NOT NULL,      -- JSON-encoded `RunStatus`
  step_entries_json  TEXT NOT NULL,      -- JSON-encoded `Vec<StepEntry>`
  degradations_json  TEXT NOT NULL DEFAULT '[]', -- JSON-encoded `Vec<DegradationEntry>` (GH #32)
  operator_sid       TEXT,
  result_ref_json    TEXT,               -- JSON-encoded `serde_json::Value`, NULL when unset
  created_at         INTEGER NOT NULL,
  updated_at         INTEGER NOT NULL
);
CREATE INDEX IF NOT EXISTS ix_runs_task_id ON runs(task_id, created_at);

degradations_json was added after the initial release (GH #32); the migration is applied idempotently on open via a PRAGMA table_info(runs) existence check followed by ALTER TABLE runs ADD COLUMN degradations_json TEXT NOT NULL DEFAULT '[]' when missing, so pre-existing database files pick up the column without a manual migration step.

Structs§

SqliteRunStore
SQLite-backed persistent RunStore.