/**
 * Cost-CLI persistence helpers (CLI.8) — split out of cost.ts for the
 * file-size budget.
 *
 * Three concerns:
 *
 *   1. `defaultConfigPath` / `readSubscriptionPools` — load configured
 *      subscription pools from `~/.opensquid/config.yaml` (`subscription_pools:`
 *      block keyed by tier). Empty file / missing block → empty record (the
 *      CLI surfaces this as "no pools configured" rather than crashing —
 *      `cost subscriptions` should still print a clean message before any
 *      pools have been declared). Malformed YAML throws (no silent fail-open).
 *
 *   2. `CostRoutingLog` — libsql-backed audit table for AUTO.7 `CostRouter`
 *      routing decisions. The router itself takes a caller-wired
 *      `audit: (entry) => void` sink (see `src/models/cost_router.ts`); the
 *      daemon wires that sink to `CostRoutingLog.append`. The CLI's
 *      `cost routing` / `cost` (default summary) read from this table.
 *
 *      Schema mirrors the `CostRoutingAuditEntry` shape: (tier, alias,
 *      success, reason, timestamp). Idempotent `CREATE TABLE IF NOT EXISTS`
 *      on first init — matches the AUTO.2 `rate_limit_buckets` + CLI.5
 *      `audit_log` posture (no versioned migration framework in opensquid
 *      yet).
 *
 *   3. `formatTimestamp` — re-exports `audit_state.ts`'s ISO formatter to
 *      keep cost-side imports inside one helper file. Same precedent as
 *      `cache.ts` importing `parseDurationToMs` from `audit_state.ts`.
 *
 * Imports from: node:fs/promises, yaml, @libsql/client,
 *   ../../models/cost_router, ../../runtime/paths.
 * Imported by: src/setup/cli/cost.ts + src/setup/cli/cost.test.ts.
 */
import { formatTimestamp } from './audit_state.js';
import type { Client } from '@libsql/client';
import type { CostTier, SubscriptionPool } from '../../models/cost_router.js';
export { formatTimestamp };
/** Per-tier subscription pools as declared in `~/.opensquid/config.yaml`. */
export type SubscriptionPoolsByTier = Partial<Record<CostTier, SubscriptionPool[]>>;
export declare const defaultConfigPath: () => string;
/** Read configured pools. Missing file / missing block → empty record. */
export declare function readSubscriptionPools(path: string): Promise<SubscriptionPoolsByTier>;
/**
 * libsql-backed log of `CostRouter.pick()` decisions. The daemon wires
 * `CostRouter`'s `audit:` sink to `append`; the CLI reads via `recent`.
 *
 * `success` stored as 0/1 (SQLite has no boolean). `reason` is the
 * machine-readable cause when `success=false` (`empty_tier` |
 * `all_rate_limited`).
 */
export interface CostRoutingRow {
    id: number;
    occurredAtMs: number;
    tier: CostTier;
    alias: string | null;
    success: boolean;
    reason: string | null;
}
export declare class CostRoutingLog {
    private readonly db;
    private initialized;
    constructor(db: Client);
    init(): Promise<void>;
    /** Append one decision. `occurredAtMs` from caller-supplied clock. */
    append(entry: {
        occurredAtMs: number;
        tier: CostTier;
        alias: string | null;
        success: boolean;
        reason?: string | null;
    }): Promise<void>;
    /** Most-recent N decisions, newest-first. */
    recent(limit: number): Promise<CostRoutingRow[]>;
    /** Aggregate row counts per (tier, alias). Used by the default `cost`
     *  summary verb to render pool usage across tiers. */
    summary(): Promise<SummaryRow[]>;
}
export interface SummaryRow {
    tier: CostTier;
    alias: string;
    picks: number;
}
export declare function renderSummary(rows: readonly SummaryRow[]): string;
export declare function renderRouting(rows: readonly CostRoutingRow[]): string;
export declare function renderSubscriptions(pools: SubscriptionPoolsByTier): string;
//# sourceMappingURL=cost_state.d.ts.map