pub fn select_compaction_range(
messages: &[Message],
keep_tail: usize,
) -> Option<CompactionRange>Expand description
Choose a split that keeps at most keep_tail messages from the end,
after preserving a leading system message, then snap for tool-pair safety.
Returns None when no compaction is needed or no safe split exists.
split_idx == messages.len() is allowed (keep system only / empty tail).