import type { UsageResponse } from '../../contracts/api-v2.types.js'; /** Append-only backing store. Implementations must expose reads over the rows and * have no mutating surface beyond `append` (no update/delete). */ export interface AppendOnlyStore { append(row: LedgerEvent): Promise | void; rows(): LedgerEvent[] | Promise; } /** In-memory append-only store (the default backing). Only ever grows. */ export declare class InMemoryLedgerStore implements AppendOnlyStore { private readonly ledger; append(row: LedgerEvent): void; rows(): LedgerEvent[]; /** Test seam: reset the ledger. Never used by production paths. */ clear(): void; } export interface LedgerEvent { id: string; tenantId: string; kind: string; /** Measured token count, or `null` when no reliable count could be produced. */ tokens: number | null; /** Milliseconds since epoch. */ at: number; } export interface AppendEvent { tenantId: string; kind: string; /** Measured tokens, or `null` when the count was unreliable. */ tokens: number | null; id?: string; at?: number; } export interface UsageQuery { /** Restrict the computation to one tenant (and the global total) — optional. */ tenantId?: string; /** Only include rows appended at or after this timestamp (ms epoch). */ since?: number; } export interface UsageLedgerOptions { backend?: AppendOnlyStore; now?: () => number; /** Test seam: deterministic id generator. Defaults to a random hex ulid-ish id. */ getId?: () => string; } export declare class UsageLedger { readonly lane = "E"; private readonly backend; private readonly now; private readonly getId; constructor(backing?: unknown, options?: UsageLedgerOptions); /** * Append one billable event to the ledger. Append-only by construction: the row * is pushed and never mutated or removed. */ append(event: AppendEvent): Promise; /** * Compute the auditable usage report for GET /v2/usage. * * Every metric is derived by summing measured ledger rows and carries * `measurement: "counted"`. A metric with nothing to measure is omitted from the * response — it is never filled with an estimate. Rows whose token count was * unreliable (`tokens: null`) are excluded from every sum and reported in * `excludedEvents`. */ computeUsage(query?: UsageQuery): Promise; } export default UsageLedger; //# sourceMappingURL=UsageLedger.d.ts.map