/** * Meter 3's fold — model usage, summarised the one way (#1054). * * The rule lives here, not in either adapter, for the reason `foldMeterReading` does: * a billable number must have ONE definition, and an adapter that summed in SQL would * float the money. Adapters list the rows in a window; this folds them. */ import { type ModelUsageEntry, type ModelUsageLine, type ModelUsageSummary, type ScopeId, type TenantId } from '@substrat-run/contracts'; /** * How long a line stays in the directory. Thirteen months — a year of usage plus the * month being billed — because this ledger IS what an invoice reconciles against, and * a reconciliation older than that is an audit, which reads the invoice. */ export declare const MODEL_USAGE_RETENTION_DAYS = 400; /** What the drain hands `recordModelUsage`. `id` is stamped by the adapter. */ export interface ModelUsageInput { /** The intent's id — the dedupe key. A second record under the same id writes nothing. */ requestId: string; line: ModelUsageLine; } /** Filter for `listModelUsage` — cursor/order/limit exactly as `OpsFailureFilter`. */ export interface ModelUsageFilter { tenantId?: TenantId; scopeId?: ScopeId; vertical?: string; /** Normalized `provider:modelId`. */ model?: string; since?: string; until?: string; limit?: number; cursor?: string; /** Default 'desc' — an operator asks "what ran lately". */ order?: 'asc' | 'desc'; } /** The window `summarizeModelUsage` folds: half-open `[since, until)`, one tenant or the fleet. */ export interface ModelUsageWindow { tenantId?: TenantId; since: string; until: string; } export declare function foldModelUsage(entries: readonly ModelUsageEntry[], window: { readAt: string; since: string; until: string; marginPercent: number; }): ModelUsageSummary; //# sourceMappingURL=model-usage.d.ts.map