Skip to content

API Reference parrot.scheduler.runstate

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

parrot.scheduler.runstate

View source

Run-state persistence for scheduled jobs (FEAT-644 spec §3 Module 2).

Alias FireContext

Re-exported from parrot.scheduler.models.FireContext.

Attribute LAST_RESULT_MAX_CHARS

Type: int

Class MemoryRunState

Process-local store for code jobs.

Parameter Type Default Description
backend str 'code'

Method MemoryRunState.stamp_success

Record a successful execution and reset the failure state.

stamp_success(job_id: str, *, result_text: str | None, fire: FireContext, next_run: Any | None) -> RunState

Parameter Type Default Description
job_id str
result_text str | None
fire FireContext
next_run Any | None

Returns: RunState

Method MemoryRunState.stamp_failure

Record a failed or unavailable execution and report a threshold crossing.

stamp_failure(job_id: str, *, status: str, error: str, fire: FireContext, threshold: int) -> tuple[RunState, bool]

Parameter Type Default Description
job_id str
status str
error str
fire FireContext
threshold int

Returns: tuple[RunState, bool]

Method MemoryRunState.stamp_delivery

Record normalized delivery outcomes without changing the run state.

stamp_delivery(job_id: str, outcomes: list[dict[str, Any]]) -> None

Parameter Type Default Description
job_id str
outcomes list[dict[str, Any]]

Method MemoryRunState.read

Return the current job state when it has been initialized.

read(job_id: str) -> RunState | None

Parameter Type Default Description
job_id str

Returns: RunState | None

Method MemoryRunState.set_enabled

Change enabled state and reset failures when re-enabling a job.

set_enabled(job_id: str, enabled: bool) -> None

Parameter Type Default Description
job_id str
enabled bool

Method MemoryRunState.clear

Remove process-local state for a deleted job.

clear(job_id: str) -> None

Parameter Type Default Description
job_id str

Class PostgresRunState

Run state as columns of navigator.service_scheduler (single-statement transitions).

Parameter Type Default Description
acquire Callable[[], Awaitable[Any]]

Method PostgresRunState.stamp_failure

Atomically record a failure and report exactly one threshold crossing.

stamp_failure(job_id: str, *, status: str, error: str, fire: FireContext, threshold: int) -> tuple[RunState, bool]

Parameter Type Default Description
job_id str
status str
error str
fire FireContext
threshold int

Returns: tuple[RunState, bool]

Method PostgresRunState.stamp_success

Atomically record a successful execution and reset failure state.

stamp_success(job_id: str, *, result_text: str | None, fire: FireContext, next_run: Any | None) -> RunState

Parameter Type Default Description
job_id str
result_text str | None
fire FireContext
next_run Any | None

Returns: RunState

Method PostgresRunState.stamp_delivery

Persist delivery outcomes without changing execution state.

stamp_delivery(job_id: str, outcomes: list[dict[str, Any]]) -> None

Parameter Type Default Description
job_id str
outcomes list[dict[str, Any]]

Method PostgresRunState.read

Read the database-backed state for a schedule.

read(job_id: str) -> RunState | None

Parameter Type Default Description
job_id str

Returns: RunState | None

Method PostgresRunState.set_enabled

Set enabled state and reset failures when a job is re-enabled.

set_enabled(job_id: str, enabled: bool) -> None

Parameter Type Default Description
job_id str
enabled bool

Method PostgresRunState.clear

Do nothing because the manager deletes database rows itself.

clear(job_id: str) -> None

Parameter Type Default Description
job_id str

Class RedisRunState

Run state as a Redis hash {prefix}{job_id}.

The prefix is normally parrot:scheduler:{registered_name}:runstate:.

Parameter Type Default Description
client 'aioredis.Redis'
prefix str

Method RedisRunState.stamp_success

Record a successful execution and reset the failure state.

stamp_success(job_id: str, *, result_text: str | None, fire: FireContext, next_run: Any | None) -> RunState

Parameter Type Default Description
job_id str
result_text str | None
fire FireContext
next_run Any | None

Returns: RunState

Method RedisRunState.stamp_failure

Atomically record a failure and report exactly one threshold crossing.

stamp_failure(job_id: str, *, status: str, error: str, fire: FireContext, threshold: int) -> tuple[RunState, bool]

Parameter Type Default Description
job_id str
status str
error str
fire FireContext
threshold int

Returns: tuple[RunState, bool]

Method RedisRunState.stamp_delivery

Record normalized delivery outcomes without changing execution state.

stamp_delivery(job_id: str, outcomes: list[dict[str, Any]]) -> None

Parameter Type Default Description
job_id str
outcomes list[dict[str, Any]]

Method RedisRunState.read

Return the current state when its Redis hash has been initialized.

read(job_id: str) -> RunState | None

Parameter Type Default Description
job_id str

Returns: RunState | None

Method RedisRunState.set_enabled

Set enabled state and reset failures when a job is re-enabled.

set_enabled(job_id: str, enabled: bool) -> None

Parameter Type Default Description
job_id str
enabled bool

Method RedisRunState.clear

Delete Redis state for a removed job.

clear(job_id: str) -> None

Parameter Type Default Description
job_id str

Alias RunState

Re-exported from parrot.scheduler.models.RunState.

Class RunStateStore

Backend contract for per-job run state (spec §2).

Method RunStateStore.stamp_success

stamp_success(job_id: str, *, result_text: str | None, fire: FireContext, next_run: Any | None) -> RunState

Parameter Type Default Description
job_id str
result_text str | None
fire FireContext
next_run Any | None

Returns: RunState

Method RunStateStore.stamp_failure

stamp_failure(job_id: str, *, status: str, error: str, fire: FireContext, threshold: int) -> tuple[RunState, bool]

Parameter Type Default Description
job_id str
status str
error str
fire FireContext
threshold int

Returns: tuple[RunState, bool]

Method RunStateStore.stamp_delivery

stamp_delivery(job_id: str, outcomes: list[dict[str, Any]]) -> None

Parameter Type Default Description
job_id str
outcomes list[dict[str, Any]]

Method RunStateStore.read

read(job_id: str) -> RunState | None

Parameter Type Default Description
job_id str

Returns: RunState | None

Method RunStateStore.set_enabled

set_enabled(job_id: str, enabled: bool) -> None

Parameter Type Default Description
job_id str
enabled bool

Method RunStateStore.clear

clear(job_id: str) -> None

Parameter Type Default Description
job_id str

Attribute STATUS_LOCK_UNAVAILABLE

Function aggregate_delivery_status

Reduce outcomes to ok / partial / failed.

aggregate_delivery_status(outcomes: list[dict[str, Any]]) -> Optional[str]

Parameter Type Default Description
outcomes list[dict[str, Any]]

Returns: Optional[str]

Attribute logger

Function truncate

Cap a stored string at LAST_RESULT_MAX_CHARS with a truncation suffix.

truncate(text: Optional[str]) -> Optional[str]

Parameter Type Default Description
text Optional[str]

Returns: Optional[str]

Alias utcnow

Re-exported from parrot.scheduler.models.utcnow.

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