pub struct ContextCompiler { /* private fields */ }Expand description
Builder + entry point for context-window assembly.
Hosts construct one ContextCompiler per session (or per agent) and reuse it across turns.
Optional dependencies (summarizer, sink) can be set once and shared via Arc.
Implementations§
Source§impl ContextCompiler
impl ContextCompiler
Sourcepub fn new(scorer: Arc<dyn RelevanceScorer>, budget: BudgetPolicy) -> Self
pub fn new(scorer: Arc<dyn RelevanceScorer>, budget: BudgetPolicy) -> Self
Construct a Tier 0 compiler with the supplied scorer and budget.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Convenience: build with the default heuristic scorer and default budget.
Sourcepub fn with_summarizer(self, summarizer: Arc<dyn Summarizer>) -> Self
pub fn with_summarizer(self, summarizer: Arc<dyn Summarizer>) -> Self
Inject a Tier 1 summarizer (M2). When absent, the orchestrator runs at Tier 0.
Sourcepub fn with_sink(self, sink: Arc<dyn ContextEmissionSink>) -> Self
pub fn with_sink(self, sink: Arc<dyn ContextEmissionSink>) -> Self
Attach a structured-event sink (mirrors ainl_compression::with_telemetry_callback).
Sourcepub fn with_embedder(self, embedder: Arc<dyn Embedder>) -> Self
pub fn with_embedder(self, embedder: Arc<dyn Embedder>) -> Self
Inject a Tier 2 / M3 embedder for relevance reranking of non-pinned segments.
Sourcepub fn probe(&self) -> CapabilityProbe
pub fn probe(&self) -> CapabilityProbe
Return the active capability probe based on injected dependencies.
Sourcepub fn compose(
&self,
latest_user_query: &str,
segments: Vec<Segment>,
existing_summary: Option<&AnchoredSummary>,
vitals: Option<&CognitiveVitals>,
) -> ComposedPrompt
pub fn compose( &self, latest_user_query: &str, segments: Vec<Segment>, existing_summary: Option<&AnchoredSummary>, vitals: Option<&CognitiveVitals>, ) -> ComposedPrompt
Compose a prompt window from segments, scored against latest_user_query, within
self.budget. existing_summary carries over from the prior turn (Tier ≥ 1 only).
vitals (when supplied) caps compression aggressiveness on low-trust turns per
SELF_LEARNING_INTEGRATION_MAP §15.3.
Algorithm (per the plan):
- Coarse selection — always-keep + heuristic scoring.
- Budget allocation — apportion across kinds per
BudgetPolicy. - Older-history compaction —
Summarizerwhen present, else heuristic compression. - Tool-result fine-grained pruning.
- Per-segment compression via
ainl_compression. - Emit telemetry events.