Runs¶
Long-lived run handles for the submit / poll / stream pattern used by the HTTP server.
from murmur.runs import (
InMemoryRunStore,
RedisRunStore,
RocksDBRunStore,
RunEvent,
RunEventType,
RunProgress,
RunState,
RunStatus,
RunStore,
SQLiteRunStore,
)
The persistent concretes (SQLite, RocksDB, Redis) are lazy-loaded
— import murmur.runs works without any of the optional extras
installed. They show up only when accessed.
RunStore Protocol¶
RunStore
¶
Pluggable persistence for in-flight runs.
The MVP ships an in-memory implementation; Redis / DB land later. Implementations must be safe to call concurrently from many tasks.
create
async
¶
Value types¶
RunState¶
RunState
¶
Coarse-grained lifecycle state for a submitted run.
RunStatus¶
RunStatus
¶
A run's current state + progress snapshot.
run_id
instance-attribute
¶
The id returned by POST /submit. Echoed back here so this status
object stands alone.
progress
class-attribute
instance-attribute
¶
progress: RunProgress | None = None
Counter snapshot. None until the runner reports the first update.
RunProgress¶
RunProgress
¶
Per-step counters reported during a run.
total
class-attribute
instance-attribute
¶
Total number of agent invocations expected for the run. 0 until
the runner knows the count (e.g. after fan-out resolution).
completed
class-attribute
instance-attribute
¶
Successfully completed invocations so far.
failed
class-attribute
instance-attribute
¶
Failed invocations so far. A run can finish in
:attr:RunState.COMPLETED with non-zero failed if the topology
tolerates partial failure.
RunEvent¶
RunEvent
¶
Stream event published over SSE for GET /runs/{run_id}/stream.
type
instance-attribute
¶
type: RunEventType
Discriminator. See :class:RunEventType for per-type payload contracts.
run_id
instance-attribute
¶
Run id this event belongs to. Always present so events stand alone when serialised.
agent
class-attribute
instance-attribute
¶
The :class:Agent name involved, when relevant.
None for run-level events (GROUP_COMPLETED, RUN_CANCELLED).
task_id
class-attribute
instance-attribute
¶
The :class:TaskSpec id, when the event is about one task in
particular. None for run-level events.
error
class-attribute
instance-attribute
¶
Stringified error message — populated only on :data:AGENT_FAILED.
timestamp
class-attribute
instance-attribute
¶
UTC time of emission.
RunEventType¶
RunEventType
¶
Discriminator for :class:RunEvent instances on the SSE stream.
AGENT_STARTED
class-attribute
instance-attribute
¶
An agent invocation began. Payload: agent, task_id.
AGENT_COMPLETED
class-attribute
instance-attribute
¶
An agent invocation finished successfully. Payload: agent, task_id.
AGENT_FAILED
class-attribute
instance-attribute
¶
An agent invocation raised. Payload: agent, task_id, error.
GROUP_COMPLETED
class-attribute
instance-attribute
¶
The whole :class:AgentGroup run finished — terminal.
RUN_CANCELLED
class-attribute
instance-attribute
¶
The run was cancelled by a client request — terminal.
Concretes¶
InMemoryRunStore¶
InMemoryRunStore
¶
SQLiteRunStore¶
Requires pip install "murmur-runtime[sqlite]".
SQLiteRunStore
¶
aiosqlite-backed :class:murmur.runs.RunStore.
store = SQLiteRunStore("runs.db") await store.create("abc", target="researcher")
Source code in src/murmur/runs/sqlite.py
RocksDBRunStore¶
Requires pip install "murmur-runtime[rocksdb]".
RocksDBRunStore
¶
rocksdict-backed :class:murmur.runs.RunStore.
store = RocksDBRunStore("./runs.db") await store.create("abc", target="researcher")
Source code in src/murmur/runs/rocksdb.py
close
async
¶
RedisRunStore¶
Requires pip install "murmur-runtime[redis-runstore]".
RedisRunStore
¶
RedisRunStore(
url: str | None = None,
*,
client: Redis | None = None,
key_prefix: str = "murmur:runs",
ttl_seconds: int = _DEFAULT_TTL_SECONDS,
)
Redis-backed :class:murmur.runs.RunStore.
Either pass url (e.g. redis://localhost:6379/0) and a client
is created via :func:redis.asyncio.from_url, or pass client=
with an existing redis.asyncio.Redis instance — useful for
pre-configured connection pools and for the test seam (FakeRedis
backed by a shared FakeServer exercises cross-instance
behaviour without Docker).
store = RedisRunStore(url="redis://localhost:6379/0") await store.create("abc", target="researcher")