klieo-runlog 3.3.1

Tier 2 observability — RunLog aggregate + replay engine for klieo agents.
Documentation
//! Built-in 2026-Q1 list-price rate table.
//!
//! Owns the literal-rate constructor that populates [`super::PriceTable`]
//! with the providers shipped by klieo. Kept in a sibling module so the
//! `Rates` + `PriceTable` types in [`super`] do not balloon with literal
//! pricing data that changes on a separate cadence from the type-level
//! lookup logic.
//!
//! See the parent [`crate::pricing`] module docs for upstream pricing URLs
//! and the rate-source refresh cadence.

use super::{PriceTable, Rates};

/// Anthropic prompt-cache read price as a fraction of the base input rate.
const CACHE_READ_MULTIPLIER: f64 = 0.1;
/// Anthropic 5-minute prompt-cache write price as a multiple of the base input
/// rate.
const CACHE_CREATION_MULTIPLIER: f64 = 1.25;

/// Construct a [`PriceTable`] pre-populated with the built-in 2026-Q1
/// list-price rates.
///
/// The hardcoded literals are statically valid (finite, non-negative);
/// `expect` documents the invariant and surfaces a panic if a future edit
/// accidentally introduces an invalid literal.
pub(super) fn with_default_rates() -> PriceTable {
    let mut t = PriceTable::new();
    let invariant = "built-in rate literal must be finite and non-negative";
    // --- Anthropic (https://www.anthropic.com/pricing) ---
    // Family aliases — versioned IDs (claude-sonnet-4-6 etc.) collapse to
    // these via PriceTable::lookup. Prompt caching bills reads at 0.1x and
    // 5-minute cache writes at 1.25x the base input rate.
    let anthropic = |prompt: f64, completion: f64| {
        Rates::new(prompt, completion).with_cache_rates(
            prompt * CACHE_READ_MULTIPLIER,
            prompt * CACHE_CREATION_MULTIPLIER,
        )
    };
    t.set("anthropic", "claude-sonnet-4-x", anthropic(0.003, 0.015))
        .expect(invariant);
    t.set("anthropic", "claude-opus-4-x", anthropic(0.015, 0.075))
        .expect(invariant);
    t.set("anthropic", "claude-haiku-4-x", anthropic(0.001, 0.005))
        .expect(invariant);
    // --- OpenAI (https://openai.com/api/pricing/) ---
    t.set("openai", "gpt-4o", Rates::new(0.0025, 0.01))
        .expect(invariant);
    t.set("openai", "gpt-4o-mini", Rates::new(0.00015, 0.0006))
        .expect(invariant);
    // --- Google (https://ai.google.dev/gemini-api/docs/pricing) ---
    t.set("google", "gemini-2.0-flash", Rates::new(0.0001, 0.0004))
        .expect(invariant);
    // --- Ollama: local execution, zero list price ---
    t.set("ollama", "*", Rates::new(0.0, 0.0)).expect(invariant);
    t
}