1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Core types for the hierarchical summary index.
//!
//! These types are persisted as part of the session JSON and must
//! remain serde-compatible across restarts.
use ;
/// Half-open `[start, end)` range over session message indices.
///
/// # Examples
///
/// ```rust
/// use codetether_agent::session::index::SummaryRange;
///
/// let r = SummaryRange::new(2, 5).unwrap();
/// assert!(r.contains(2));
/// assert!(r.contains(4));
/// assert!(!r.contains(5));
/// assert!(SummaryRange::new(5, 5).is_none());
/// ```
/// Granularity at which a [`SummaryNode`] was produced.
///
/// Step 18 uses this to choose between turn-level RLM summaries
/// and coarser phase-/session-level rollups.
/// One cached summary entry — produced once, consumed many times until
/// the underlying range is invalidated.
///
/// # Examples
///
/// ```rust
/// use codetether_agent::session::index::{Granularity, SummaryNode};
///
/// let node = SummaryNode {
/// content: "Discussed auth refactor".into(),
/// target_tokens: 512,
/// granularity: Granularity::Turn,
/// generation: 1,
/// };
/// assert_eq!(node.content, "Discussed auth refactor");
/// ```
/// Upper bound on cached summaries before LRU eviction kicks in.
///
/// Chosen so the index sidecar stays under ~1 MB for typical sessions.
pub const MAX_CACHED_SUMMARIES: usize = 128;