Skip to content

cayu.storage.product_operations_postgres

Public Cayu API. Definitions are grouped by their public source module, and definitions from private implementation modules appear on their package’s page; adding a symbol does not move existing links. The import shown at each entry is a supported public namespace. Read the Python API overview and install the required extra.

from cayu.storage import PostgresProductOperationStore

Tenant/resource authority shared by product service processes on PostgreSQL.

This store, not Cayu labels, metadata, or runtime identifiers, is the product authorization boundary. Product reads are tenant-qualified by public id; the private session-id lookup exists only for trusted continuation hooks.

Every claim, heartbeat, receipt, and settlement locks the one operation row and evaluates lease expiry against the database clock after that lock, so service processes on different hosts agree on ownership. Terminal updates are conditional on the current claim, and a completed result requires the content-bound publication receipt written before Cayu session completion.

cayu_product_operations joins Cayu’s shared revision history; like the other Postgres stores, the default schema_mode is VALIDATE and cayu storage migrate creates or upgrades the table. clock replaces the database lease clock for tests.

Bases: _PostgresStoreBase.

Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.

Name Type Default
category ServiceIdentityStoreKind ServiceIdentityStoreKind.DURABLE
PostgresProductOperationStore.__init__(conninfo: str | None=None, *, pool: AsyncConnectionPool | None=None, min_size: int=1, max_size: int=8, schema_mode: schema.SchemaMode=schema.SchemaMode.VALIDATE, clock: Callable[[], datetime] | None=None) -> None
async PostgresProductOperationStore.ensure_schema() -> None

Open the pool and reconcile the schema now (per schema_mode).

Normally reconciliation happens lazily on first use; the cayu storage CLI calls this to run a migrate (or validate) as an explicit step.

async PostgresProductOperationStore.close() -> None
async PostgresProductOperationStore.reserve(*, tenant_id: str, subject_id: str, idempotency_key: str, request_fingerprint: str, public_id: str, work_id: str, session_id: str, task_id: str, request_text: str) -> ProductOperationReservation
async PostgresProductOperationStore.find(*, tenant_id: str, public_id: str) -> ProductOperation | None
async PostgresProductOperationStore.find_by_session_id(*, session_id: str) -> ProductOperation | None
async PostgresProductOperationStore.claim_execution(*, work_id: str, claim_id: str, lease_seconds: int) -> ProductOperationExecutionClaim | None
async PostgresProductOperationStore.heartbeat_execution(*, work_id: str, claim_id: str, lease_seconds: int) -> bool
async PostgresProductOperationStore.release_execution(*, work_id: str, claim_id: str) -> bool
async PostgresProductOperationStore.record_result_receipt(*, work_id: str, claim_id: str, receipt: ProductResultReceipt) -> ProductResultReceipt
async PostgresProductOperationStore.record_recovery_status(*, work_id: str, claim_id: str, recovery_status: ProductRecoveryStatus) -> ProductOperation
async PostgresProductOperationStore.finish(*, work_id: str, claim_id: str, status: Literal['completed', 'failed'], result: str | None) -> ProductOperation

Release source · Runtime guarantees · Capability guides