Skip to content

API Reference parrot.bots.flows.core.checkpoint.store.durable

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.bots.flows.core.checkpoint.store.durable

View source

DurableCheckpointStore — sqlite | postgres | mongodb (FEAT-399, TASK-2050).

The durable tier: suspended flows are dumped here for indefinite recovery; durable=True flows write-through on every checkpoint. One asyncdb-parametrized implementation covering all three drivers (FEAT-147 backend pattern). Storage model: one row/document per checkpoint keyed (flow_id, checkpoint_id), with payload (the ormsgpack bytes from FlowStateSerializer) as the source of truth — the other columns are indexed metadata mirrored from the checkpoint for cheap filtering (list_flows(status=...)) without decoding every payload.

No TTL/expiry: durability is the point (spec §1 two-tier rationale); deletion is explicit via delete_flow or the HTTP handlers (TASK-2055).

Durable stores are NOT the lease authority — the checkpointer always takes leases on the ephemeral Redis store (spec §3 Module 6); the lease methods here raise NotImplementedError.

Driver notes (verified empirically against throwaway sqlite/postgres/ mongo instances — the installed asyncdb version's per-driver method signatures differ enough that this is NOT a copy-paste of PostgresResultStorage):

  • sqlite: execute() binds named :param kwargs; fetchrow()/ fetch_one() bind a positional list via the literal parameters= kwarg (? placeholders); fetch_all() wraps arbitrary kwargs into a named-parameter dict (:param placeholders again).
  • postgres: the asyncdb pg driver's own fetch/fetchrow are cursor-only (no sentence argument) in the installed version — fetch_one/fetch_all (positional $1, $2, ...) are the sentence-taking read methods to use instead.
  • mongodb: the asyncdb module is named mongo (not mongodb) and requires a params dict (host/port/database/...) — passing only a raw dsn= string is silently discarded by the driver's DSN builder. execute(collection, operation, *args, **kwargs) dispatches to the underlying Motor collection method; query() supports sort=/limit= kwargs and returns [docs, error].

Alias CheckpointStore

Re-exported from parrot.bots.flows.core.checkpoint.store.base.CheckpointStore.

Class DurableCheckpointStore

Durable checkpoint tier: one row/document per (flow_id, checkpoint_id).

Parameter Type Default Description
driver str 'sqlite' One of "sqlite", "postgres", "mongodb".
dsn str | None None Backend DSN; defaults to FLOW_CHECKPOINT_DURABLE_STORE then a driver-specific fallback.

Method DurableCheckpointStore.put

Upsert a checkpoint keyed by (flow_id, checkpoint_id).

put(checkpoint: FlowCheckpoint) -> None

Parameter Type Default Description
checkpoint FlowCheckpoint

Method DurableCheckpointStore.latest

Return the checkpoint with the highest checkpoint_id for a flow.

latest(flow_id: str) -> FlowCheckpoint | None

Parameter Type Default Description
flow_id str

Returns: FlowCheckpoint | None

Method DurableCheckpointStore.get

Return a specific checkpoint by id.

get(flow_id: str, checkpoint_id: int) -> FlowCheckpoint | None

Parameter Type Default Description
flow_id str
checkpoint_id int

Returns: FlowCheckpoint | None

Method DurableCheckpointStore.history

Return the checkpoint history for a flow, newest first.

history(flow_id: str, limit: int = 10) -> list[FlowCheckpoint]

Parameter Type Default Description
flow_id str
limit int 10

Returns: list[FlowCheckpoint]

Method DurableCheckpointStore.list_flows

List flows using each flow's latest checkpoint, optionally by status.

list_flows(status: str | None = None) -> list[dict[str, Any]]

Parameter Type Default Description
status str | None None

Returns: list[dict[str, Any]]

Method DurableCheckpointStore.delete_flow

Delete every checkpoint for a flow.

delete_flow(flow_id: str) -> None

Parameter Type Default Description
flow_id str

Method DurableCheckpointStore.acquire_lease

Durable stores are not the lease authority.

acquire_lease(flow_id: str, holder: str, ttl: int = 60) -> bool

Parameter Type Default Description
flow_id str
holder str
ttl int 60

Returns: bool

Raises:

  • NotImplementedError — Always — the checkpointer always takes leases on the ephemeral Redis store (spec §3 Module 6).

Method DurableCheckpointStore.renew_lease

Durable stores are not the lease authority.

renew_lease(flow_id: str, holder: str, ttl: int = 60) -> bool

Parameter Type Default Description
flow_id str
holder str
ttl int 60

Returns: bool

Raises:

  • NotImplementedError — Always — see :meth:acquire_lease.

Method DurableCheckpointStore.release_lease

Durable stores are not the lease authority.

release_lease(flow_id: str, holder: str) -> None

Parameter Type Default Description
flow_id str
holder str

Raises:

  • NotImplementedError — Always — see :meth:acquire_lease.

Method DurableCheckpointStore.close

Release the underlying connection. Safe to call multiple times.

close() -> None

Alias FLOW_CHECKPOINT_DURABLE_STORE

Re-exported from parrot.conf.FLOW_CHECKPOINT_DURABLE_STORE.

Alias FlowCheckpoint

Re-exported from parrot.bots.flows.core.checkpoint.model.FlowCheckpoint.

Alias FlowStateSerializer

Re-exported from parrot.bots.flows.core.checkpoint.serializer.FlowStateSerializer.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally