Expand description
klieo-runlog — Tier 2 observability for klieo agents.
This crate ships:
- A
RunLogaggregate type (the spec §8.2 view:run_id,agent,started_at,finished_at,status,steps,tokens,cost_estimate). - A pluggable
RunLogStoretrait. Default in-memory; SQLite behindsqlitefeature. - Deterministic
compaction(drop-by-rule). LLM-summarise compaction behindcompaction-llmfeature. - A deterministic-only
replayengine that re-runs recorded LLM + tool calls.
§Design: projection over EpisodicMemory, not a new trait
RunLog is not a separate sink. It is a projection computed by walking
a Vec<klieo_core::Episode> returned from any
EpisodicMemory::replay(run_id). The crate adds zero traits to
klieo-core. Plan #11 froze that surface.
Typical wiring:
EpisodicMemory --(replay)--> Vec<Episode> --(project)--> RunLog --(put)--> RunLogStore§Replay caveats
replay is deterministic-only. It asserts that user-supplied
test-double LlmClient + ToolInvoker produce byte-identical outputs to
the recorded ones. Side effects that do not flow through these traits
(timestamps, randomness, network calls outside the recorded LLM/tool
calls) cannot be replayed.
Re-exports§
pub use crate::capture::Capture;pub use crate::capture_sink::RunLogCaptureSink;pub use crate::capture_store::gc_captures;pub use crate::capture_store::load_capture;pub use crate::capture_store::persist_capture;pub use crate::capture_store::CAPTURE_BUCKET;pub use crate::compaction::LlmCompaction;pub use crate::compaction::CompactionPolicy;pub use crate::compaction::DeterministicCompaction;pub use crate::divergence::replay_with_divergence;pub use crate::divergence::DivergenceReport;pub use crate::divergence::ReplayMode;pub use crate::divergence::ReproVerdict;pub use crate::divergence::StepDivergence;pub use crate::error::RunLogError;pub use crate::fingerprint::request_fingerprint;pub use crate::pricing::PriceTable;pub use crate::pricing::Rates;pub use crate::pricing::RatesError;pub use crate::projector::project;pub use crate::projector::project_with_llm_io;pub use crate::projector::project_with_price_table;pub use crate::replay::replay;pub use crate::replay_llm::ReplayLlmClient;pub use crate::store::InMemoryRunLogStore;pub use crate::store::RunLogQuery;pub use crate::store::RunLogStore;pub use crate::store_sqlite::SqliteRunLogStore;pub use crate::types::Cost;pub use crate::types::LlmIo;pub use crate::types::RunLog;pub use crate::types::RunStatus;pub use crate::types::Step;pub use crate::types::StepKind;pub use crate::types::Usage;
Modules§
- capture
- The
Captureenvelope (ADR-046): a single serializable artifact bundling everything needed to replay a run without a live store — theRunLog, the parallelLlmIosidecar carrying prompt/completion text, and Option-typed provider-version / seed / memory metadata filled in when available. - capture_
sink - Live
CaptureSinkthat accumulates replayable LLM I/O (ADR-048). - capture_
store KvStore-backed persistence for theCaptureartifact (ADR-046). The bucket holds one JSON blob per run, keyed by run id — the durable, cross-process channel for embedded and distributed callers. Offline operator export/import of the same serde blob goes through theklieo-replayCLI’s file path; both shareCapture’s serialization.- compaction
CompactionPolicytrait + deterministic and (optional) LLM-summarise impls.- divergence
- Soft-compare reproducibility reporting (ADR-046): replay a recorded run and collect per-step textual divergences instead of failing on the first mismatch, so non-deterministic runs yield an auditable report.
- error
RunLogError— the only error surface for this crate.- fingerprint
- Stable request fingerprint for replay-keying (ADR-048).
- pricing
- Pricing tables and per-(provider, model) USD rate lookup.
- projector
Episodestream →RunLogaggregate projection.- replay
- Deterministic-only replay engine.
- replay_
llm - Order-keyed structured LLM double for agent-loop re-drive (ADR-048).
- store
RunLogStoretrait and in-memory default implementation.- store_
sqlite - SQLite-backed
RunLogStore. Single-table schema withstepsstored as JSON. - test_
utils - Test helpers for downstream consumers that want to drive klieo’s
deterministic
replayengine without hand-wiring aFakeLlmClient. - types
- Aggregate types for the RunLog projection.