Snodo.Extensions.Tasks.Store.SQLite (snodo_tasks_sqlite v0.2.0)

Copy Markdown View Source

Single-host SQLite persistence for the MCP Tasks extension.

This adapter accepts an application-owned Ecto.Repo; it never starts a repository, creates a database file, or runs migrations. Task snapshots and serializable work descriptors are stored atomically as versioned JSON. Each applied event is committed to a separate ledger in the same transaction as the aggregate update.

SQLite has no row locks and permits only one writer. Every store mutation therefore uses an IMMEDIATE transaction, acquiring the database write reservation before it reads availability, lease, revision, or clock state. Competing writers wait according to the application Repo's :busy_timeout. Exhausted contention is normalized to {:error, :database_busy}.

The supported deployment boundary is a file-backed WAL database on one host. Recovery remains at least once, so applications must deduplicate external effects with Snodo.Extensions.Tasks.Work.idempotency_key.

Summary

Functions

Audits one bounded page of aggregate and ledger rows.

Checks the migration and required file-backed WAL Repo settings.

Returns the validated applied-event history visible to request access.

Builds immutable adapter configuration around an application-owned Repo.

Builds adapter configuration or raises ArgumentError.

Types

audit_report()

@type audit_report() :: %{
  checked: non_neg_integer(),
  errors: [map()],
  next_cursor: String.t() | nil
}

Functions

audit(config, opts \\ [])

@spec audit(Snodo.Extensions.Tasks.Store.SQLite.Config.t(), keyword()) ::
  {:ok, audit_report()} | {:error, term()}

Audits one bounded page of aggregate and ledger rows.

check_schema(config)

@spec check_schema(Snodo.Extensions.Tasks.Store.SQLite.Config.t()) ::
  :ok | {:error, term()}

Checks the migration and required file-backed WAL Repo settings.

history(config, task_id, access)

@spec history(Snodo.Extensions.Tasks.Store.SQLite.Config.t(), String.t(), term()) ::
  {:ok, [map()]} | :not_found | {:error, term()}

Returns the validated applied-event history visible to request access.

new(opts)

@spec new(keyword()) ::
  {:ok, Snodo.Extensions.Tasks.Store.SQLite.Config.t()} | {:error, term()}

Builds immutable adapter configuration around an application-owned Repo.

new!(opts)

Builds adapter configuration or raises ArgumentError.