Skip to content

cayu.storage.budget_ledger

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 SQLiteBudgetLedger

SQLite-backed atomic budget reservation ledger.

The cayu_budget_reservations table is owned by the shared migration machinery (ADR 0001 revision 8), not created ad hoc by this class.

Bases: BudgetLedger.

async SQLiteBudgetLedger.reserve_batch(*, members, binding_id=None, binding_authority_digest=None, binding_allowance=None, binding_consumption_id=None) -> BudgetBatchResult

Reserve all ceilings in one SQLite write transaction.

async SQLiteBudgetLedger.register_budget_binding(*, binding_id: str, authority_digest: str, allowance: int) -> None
SQLiteBudgetLedger.durable_state_paths() -> tuple[Path, ...]

Return the primary SQLite database file.

async SQLiteBudgetLedger.claim_reservation_identity(*, reservation_id: str, publication_session_id: str, publication_id: str) -> None
SQLiteBudgetLedger.reservation_ttl_seconds() -> int | None
async SQLiteBudgetLedger.heartbeat(*, reservation_id: str) -> bool
async SQLiteBudgetLedger.mark_dispatched(*, reservation_ids: tuple[str, ...], dispatch_id: str, dispatched_at: datetime | None=None) -> tuple[BudgetReservationRecord, ...]
async SQLiteBudgetLedger.release_pre_provider_dispatch(*, reservation_ids: tuple[str, ...], dispatch_id: str, reason: str, occurred_at: datetime | None=None) -> tuple[BudgetReconciliation, ...]
async SQLiteBudgetLedger.reserve(*, reservation_id: str | None=None, limit: BudgetLimit, session_id: str, agent_name: str, provider_name: str, model: str, model_attempt_identity: ModelAttemptIdentity, environment_name: str | None=None, settlement_event_payload: dict[str, Any] | None=None, settlement_fallback: BudgetSettlementFallback | None=None, requested_amount: Decimal | None=None, billing_identity: BillingIdentity | None=None, effective_at: datetime | None=None) -> BudgetReservationResult
async SQLiteBudgetLedger.reconcile(*, reservation_id: str, actual_amount: Decimal, settlement_kind: Literal['completed', 'conservative']='completed', reason: str | None=None, occurred_at: datetime | None=None, billing_identity: BillingIdentity | None=None, pricing: BudgetReconciliationPricing | None=None) -> BudgetReconciliation
async SQLiteBudgetLedger.release(*, reservation_id: str, reason: str, occurred_at: datetime | None=None) -> BudgetReconciliation
async SQLiteBudgetLedger.load_reservation(reservation_id: str) -> BudgetReservationRecord | None
async SQLiteBudgetLedger.load_settlement(settlement_id: str) -> BudgetSettlementRecord | None
async SQLiteBudgetLedger.list_pending_settlements(*, session_id: str | None=None, after: BudgetSettlementCursor | None=None, limit: int=100) -> list[BudgetSettlementRecord]
async SQLiteBudgetLedger.mark_settlement_event_published(*, settlement_id: str, event_id: str) -> BudgetSettlementRecord
SQLiteBudgetLedger.__init__(path: str | Path, *, clock: Callable[[], datetime] | None=None, reservation_ttl_seconds: int | None=DEFAULT_RESERVATION_TTL_SECONDS, schema_mode: schema.SchemaMode=schema.SchemaMode.CREATE) -> None
async SQLiteBudgetLedger.close() -> None

Release source · Runtime guarantees · Capability guides