import type { CapacityReservationLedger } from './reserveConfirm.js'; /** Options for {@link createInMemoryCapacityLedger}. */ export interface InMemoryCapacityLedgerOptions { /** How long a hold counts toward the limit before it expires, in milliseconds. Default 60,000. A safe integer >= 1. */ holdMs?: number; /** The clock, in epoch milliseconds, used for expiry. Default `Date.now`. */ now?: () => number; } /** A {@link CapacityReservationLedger} that also lets a test look at its counters. */ export interface InMemoryCapacityLedger extends CapacityReservationLedger { /** Confirmed usage and the unexpired holds for `key`. */ usage(key: string): { confirmed: number; held: number; }; } /** * An in-memory ledger for tests. It follows the contract in * {@link CapacityReservationLedger}: `reserveCapacity` creates a hold only when * confirmed usage plus unexpired holds plus the request's `amount` (default 1) * is at most `limit`, answers `operation_in_progress` for a repeated unresolved * `(key, operationId)` and `operation_terminal` for a repeated settled one; * confirm and release are idempotent. A repeated confirm after a release, or a * release after a confirm, throws, because a settled hold must not flip. * Confirming with a settlement records `settlement.amount`, which may exceed * the hold; without one it records the hold's size. * * Expired holds stop counting but stay unresolved, as in the contract. The * reservation's `expiresAt` is built from `now()` and is checked by * `withCapacityReservation` against the real `Date.now()`, so inject a `now` * only when it tracks the real clock. */ export declare function createInMemoryCapacityLedger(options?: InMemoryCapacityLedgerOptions): InMemoryCapacityLedger;