import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js'; import type { Period } from '../types/index.js'; export interface BillingDiffRow { agent: string; estimated_usd: number; actual_usd: number; delta_usd: number; delta_pct: number; } /** * Why a drift percentage could not be computed. `null` means it could. * * - `no_billing_records` — no provider billing rows exist for the period at * all. Nothing was imported; there is no "actual" to compare against. * - `zero_actual_billing` — rows exist but total $0.00, so the denominator is * still absent even though the import ran. */ export type BillingDiffIncomparableReason = 'no_billing_records' | 'zero_actual_billing'; /** * Estimated-vs-actual drift as a percentage, or `null` when there is no actual * to divide by. * * Returning `null` rather than `0` is the point. Three call sites independently * wrote `actual > 0 ? (delta / actual) * 100 : 0`, and every one of them then * rendered the fallback as a measured "0.0%" — reporting perfect agreement for * the case where nothing was there to agree with. */ export declare function billingDeltaPct(estimatedUsd: number, actualUsd: number): number | null; export interface BillingDiffSummary { period: Period; estimated_usd: number; actual_usd: number; delta_usd: number; delta_pct: number; threshold_pct: number; is_alert: boolean; /** * Whether `delta_pct` is a measurement at all. False means the two sides * could not be compared, and `delta_pct` carries 0 only because the type is * a number — read this before reporting the percentage as agreement. */ comparable: boolean; incomparable_reason: BillingDiffIncomparableReason | null; by_agent: BillingDiffRow[]; by_provider: Record; } export declare function queryBillingDiff(db: Database, period: Period, thresholdPct?: number): BillingDiffSummary; /** * The health verdict `economy doctor` reports for billing drift. * * Kept beside the diff rather than in the CLI because the interesting case is * a semantic one: an unmeasurable drift must not render as a measured 0.0%. * A check that cannot distinguish "the sides agree" from "there is nothing to * compare" cannot fail, and this one is consulted to decide whether the rest * of the tool's numbers are trustworthy. */ export declare function billingDriftCheck(diff: BillingDiffSummary): { ok: boolean; msg: string; }; //# sourceMappingURL=billing-diff.d.ts.map