llm_tool/types/truncation/alignment.rs
1//! Boundary alignment policies for truncation cuts.
2
3/// Maximum window (in bytes) to scan backward or forward for a newline boundary.
4///
5/// Prevents pathological single-line inputs from collapsing the available budget.
6pub const MAX_LINE_SCAN_WINDOW: usize = 4096;
7
8/// Boundary snapping strategy for middle-out truncation.
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
10pub enum TruncationAlignment {
11 /// Snap strictly to valid UTF-8 character boundaries (default).
12 #[default]
13 CharBoundary,
14 /// Snap head back to preceding newline and tail forward to following newline,
15 /// degrading gracefully to character boundary if no newline is found within
16 /// [`MAX_LINE_SCAN_WINDOW`].
17 LineBoundary,
18}