1use thiserror::Error;
8
9#[path = "context/budget.rs"]
10mod budget;
11#[path = "context/input.rs"]
12mod input;
13#[path = "context/projection.rs"]
14mod projection;
15
16pub use budget::{
17 CheckpointDecision, ContextBudget, ResolvedContextWindow, decide_checkpoint,
18 resolve_context_window,
19};
20pub use input::{
21 CompactedCheckpoint, CompactedCheckpointSummary, ContextEntry, ContextSummary, ProjectRules,
22 SessionContextSnapshot, TaskAnchor,
23};
24pub(crate) use projection::compacted_checkpoint_wrapper_token_ceiling;
25pub use projection::{CompiledContext, CompiledContextSection, ContextCompiler};
26
27pub const DEFAULT_CONTEXT_WINDOW_FALLBACK_TOKENS: u64 = 272_000;
29
30#[derive(Debug, Error, PartialEq, Eq)]
32pub enum ContextError {
33 #[error("{field} must not be blank")]
35 BlankField {
36 field: &'static str,
38 },
39
40 #[error("{field} must not contain control characters other than newline or tab")]
42 InvalidControlCharacter {
43 field: &'static str,
45 },
46
47 #[error("invalid context budget: {reason}")]
49 InvalidBudget {
50 reason: &'static str,
52 },
53
54 #[error("invalid context window: {reason}")]
56 InvalidContextWindow {
57 reason: &'static str,
59 },
60
61 #[error("memory item {memory_id} has no provenance metadata")]
63 MemoryWithoutEvidence {
64 memory_id: String,
66 },
67}
68
69#[cfg(test)]
70mod tests;