ETS-backed task store. Default implementation of ConduitMcp.Tasks.Store.
All state lives in the named ETS table :conduit_mcp_tasks. The table
is owned by a long-lived ConduitMcp.EtsOwner process (ConduitMcp.Tasks.EtsStore.Owner) started
from ConduitMcp.Application so the table outlives short-lived request
processes — without this, a Bandit request handler that creates the
table dies with it, and the next request sees an empty table. The
table is :public so any process can read and write; concurrency is
safe because each task id is the row key and rows are written
atomically.
This store is in-memory only. Terminal-state rows accumulate until the
BEAM restarts; pair it with ConduitMcp.Tasks.Janitor to evict them on
an interval.
Summary
Functions
Cancels a task by setting status to "cancelled".
Removes terminal-state tasks (completed, failed, cancelled) older
than ttl_ms. Tasks in working or input_required are never evicted.
Returns the number of rows removed.
Creates a new task with the given id and metadata. Returns the stored task,
or {:error, :task_limit_reached} when the configured row cap is hit.
Deletes a task. Returns :ok whether or not it existed.
Fetches a task by id.
Lists tasks matching opts, evaluated as a single :ets.select/3 match
spec so filtering happens in the C layer and only matching rows are copied
into the caller's heap.
Merges updates into the existing task. Returns the new task or
{:error, :not_found}.
Functions
Cancels a task by setting status to "cancelled".
Removes terminal-state tasks (completed, failed, cancelled) older
than ttl_ms. Tasks in working or input_required are never evicted.
Returns the number of rows removed.
Creates a new task with the given id and metadata. Returns the stored task,
or {:error, :task_limit_reached} when the configured row cap is hit.
The cap defaults to 10000 rows and is configurable via
config :conduit_mcp, :tasks_max_rows. Terminal-state rows are reclaimed
by ConduitMcp.Tasks.Janitor; working/input_required rows are not, so
the cap is the backstop against unbounded growth.
Deletes a task. Returns :ok whether or not it existed.
Fetches a task by id.
Lists tasks matching opts, evaluated as a single :ets.select/3 match
spec so filtering happens in the C layer and only matching rows are copied
into the caller's heap.
Options:
:owner— the caller's principal restricts to rows that principal may see: its own plus unowned ones, or only its own under:tasks_require_owner.nil= no principal: sees only unowned tasks; nothing under:tasks_require_owner(seeConduitMcp.Tasks.get/2). Pass:any(the default) for the unscoped listing.:status— restrict to one task status.:limit— maximum number of rows to return.
Merges updates into the existing task. Returns the new task or
{:error, :not_found}.