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.
SQLiteBudgetLedger
Section titled “SQLiteBudgetLedger”from cayu.storage import SQLiteBudgetLedgerSQLite-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.
reserve_batch (method)
Section titled “reserve_batch (method)”async SQLiteBudgetLedger.reserve_batch(*, members, binding_id=None, binding_authority_digest=None, binding_allowance=None, binding_consumption_id=None) -> BudgetBatchResultReserve all ceilings in one SQLite write transaction.
register_budget_binding (method)
Section titled “register_budget_binding (method)”async SQLiteBudgetLedger.register_budget_binding(*, binding_id: str, authority_digest: str, allowance: int) -> Nonedurable_state_paths (method)
Section titled “durable_state_paths (method)”SQLiteBudgetLedger.durable_state_paths() -> tuple[Path, ...]Return the primary SQLite database file.
claim_reservation_identity (method)
Section titled “claim_reservation_identity (method)”async SQLiteBudgetLedger.claim_reservation_identity(*, reservation_id: str, publication_session_id: str, publication_id: str) -> Nonereservation_ttl_seconds (property)
Section titled “reservation_ttl_seconds (property)”SQLiteBudgetLedger.reservation_ttl_seconds() -> int | Noneheartbeat (method)
Section titled “heartbeat (method)”async SQLiteBudgetLedger.heartbeat(*, reservation_id: str) -> boolmark_dispatched (method)
Section titled “mark_dispatched (method)”async SQLiteBudgetLedger.mark_dispatched(*, reservation_ids: tuple[str, ...], dispatch_id: str, dispatched_at: datetime | None=None) -> tuple[BudgetReservationRecord, ...]release_pre_provider_dispatch (method)
Section titled “release_pre_provider_dispatch (method)”async SQLiteBudgetLedger.release_pre_provider_dispatch(*, reservation_ids: tuple[str, ...], dispatch_id: str, reason: str, occurred_at: datetime | None=None) -> tuple[BudgetReconciliation, ...]reserve (method)
Section titled “reserve (method)”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) -> BudgetReservationResultreconcile (method)
Section titled “reconcile (method)”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) -> BudgetReconciliationrelease (method)
Section titled “release (method)”async SQLiteBudgetLedger.release(*, reservation_id: str, reason: str, occurred_at: datetime | None=None) -> BudgetReconciliationload_reservation (method)
Section titled “load_reservation (method)”async SQLiteBudgetLedger.load_reservation(reservation_id: str) -> BudgetReservationRecord | Noneload_settlement (method)
Section titled “load_settlement (method)”async SQLiteBudgetLedger.load_settlement(settlement_id: str) -> BudgetSettlementRecord | Nonelist_pending_settlements (method)
Section titled “list_pending_settlements (method)”async SQLiteBudgetLedger.list_pending_settlements(*, session_id: str | None=None, after: BudgetSettlementCursor | None=None, limit: int=100) -> list[BudgetSettlementRecord]mark_settlement_event_published (method)
Section titled “mark_settlement_event_published (method)”async SQLiteBudgetLedger.mark_settlement_event_published(*, settlement_id: str, event_id: str) -> BudgetSettlementRecordinit (method)
Section titled “init (method)”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) -> Noneclose (method)
Section titled “close (method)”async SQLiteBudgetLedger.close() -> None