Skip to main content

ContextCompiler

Struct ContextCompiler 

Source
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

Source

pub fn new(scorer: Arc<dyn RelevanceScorer>, budget: BudgetPolicy) -> Self

Construct a Tier 0 compiler with the supplied scorer and budget.

Source

pub fn with_defaults() -> Self

Convenience: build with the default heuristic scorer and default budget.

Source

pub fn with_summarizer(self, summarizer: Arc<dyn Summarizer>) -> Self

Inject a Tier 1 summarizer (M2). When absent, the orchestrator runs at Tier 0.

Source

pub fn with_sink(self, sink: Arc<dyn ContextEmissionSink>) -> Self

Attach a structured-event sink (mirrors ainl_compression::with_telemetry_callback).

Source

pub fn with_embedder(self, embedder: Arc<dyn Embedder>) -> Self

Inject a Tier 2 / M3 embedder for relevance reranking of non-pinned segments.

Source

pub fn probe(&self) -> CapabilityProbe

Return the active capability probe based on injected dependencies.

Source

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):

  1. Coarse selection — always-keep + heuristic scoring.
  2. Budget allocation — apportion across kinds per BudgetPolicy.
  3. Older-history compaction — Summarizer when present, else heuristic compression.
  4. Tool-result fine-grained pruning.
  5. Per-segment compression via ainl_compression.
  6. Emit telemetry events.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more