Skip to main content

codetether_rlm/context_trace/
trace.rs

1use super::ContextEvent;
2use serde::{Deserialize, Serialize};
3use std::collections::VecDeque;
4
5/// Maximum number of events to keep in the trace buffer.
6pub(super) const MAX_EVENTS: usize = 1000;
7
8/// Context trace for a single RLM analysis run.
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct ContextTrace {
11    /// Maximum token budget.
12    pub(super) max_tokens: usize,
13    /// Events logged during the run.
14    pub(super) events: VecDeque<ContextEvent>,
15    /// Total tokens accumulated.
16    pub(super) total_tokens: usize,
17    /// Iteration number.
18    pub(super) iteration: usize,
19}
20
21impl ContextTrace {
22    /// Create a new context trace with the given token budget.
23    pub fn new(max_tokens: usize) -> Self {
24        Self {
25            max_tokens,
26            events: VecDeque::with_capacity(64),
27            total_tokens: 0,
28            iteration: 0,
29        }
30    }
31}