/** * The measured side of the limits policy: what a usage log says each scope * has already spent. * * `judgeLimits` judges; this measures. The split is the product's oldest * rule — the judging function must be pure and instant, so whatever reads * and prices records happens once, here, and the doors keep the result. * * **Absence is `null`, never zero.** A log with no clock cannot say what * today has cost; a log that records no sessions cannot say what a session * has spent. Both come back `null`, and `judgeLimits` turns a `null` into * `cannot-tell` rather than an approval. The one deliberate asymmetry: a log * that *does* record sessions and has never seen this one answers `0` — the * history of a conversation that has not started is complete and empty, * which is a measurement, not an absence. * * **Session keys never leave this module.** The index groups by them — that * is the whole job — but the map lives in door memory, `positionAt` returns * only dollar figures, and nothing here is serialised. The guarantee the * usage module states (a session key is somebody's conversation and is never * printed) holds through this door too. */ import type { UsageRecord } from './usage.js'; import type { PricingCatalogue } from './pricing.js'; import type { MeasuredPosition } from './judgement.js'; /** * Everything a door needs to answer `positionAt` in constant time, built * once from the log it was pointed at. */ export interface MeasuredIndex { /** Spend inside the current UTC day. Null when no record carries a clock. */ dayUsd: number | null; /** The UTC day the figure covers. Null exactly when `dayUsd` is. */ dayWindow: { fromMs: number; toMs: number; } | null; /** Whether any record carried a label / a session at all. */ labelsSeen: boolean; sessionsSeen: boolean; /** Priced spend per label. Keys are labels, which do print. */ labels: ReadonlyMap; /** Priced spend per session. Keys are session identifiers — never printed. */ sessions: ReadonlyMap; /** Whether the log held any records at all. */ any: boolean; /** Records whose model the catalogue cannot price — money nobody can see. */ unpriced: number; } /** * Prices and groups a parsed usage log, once. * * An unpriced record contributes nothing to any figure and is **counted** * instead of dropped silently: a door that reports "measured $3" over a log * with a thousand unpriced records is wrong by an amount nobody can see, in * the flattering direction, and `unpriced` is how the door says so. */ export declare function indexUsage(records: readonly UsageRecord[], options: { catalogue: PricingCatalogue; on?: Date; }): MeasuredIndex; /** * The measured position for one proposed call, from an index built once. * * A scope the log cannot see is `null`; a scope it can see and has nothing * recorded for is `0`. The difference is the difference between "unknown" * and "a conversation that has not started yet", and collapsing them is how * a dead log approves a live spend. */ export declare function positionAt(index: MeasuredIndex, call: { label?: string; session?: string; }): MeasuredPosition; //# sourceMappingURL=position.d.ts.map