Struct ContextAssembler
Source pub struct ContextAssembler {
config: CellstateConfig,
segment_budget: Option<TokenBudget>,
}Expand description
Context assembler that builds context windows from packages. Adds sections by priority until budget is exhausted.
Fields§
§config: CellstateConfig§segment_budget: Option<TokenBudget>Implementations§
Source§impl ContextAssembler
impl ContextAssembler
Sourcepub fn new(config: CellstateConfig) -> Result<ContextAssembler, CellstateError>
pub fn new(config: CellstateConfig) -> Result<ContextAssembler, CellstateError>
Create a new context assembler with the given configuration.
Sourcepub fn with_segment_budget(
config: CellstateConfig,
budget: TokenBudget,
) -> Result<ContextAssembler, CellstateError>
pub fn with_segment_budget( config: CellstateConfig, budget: TokenBudget, ) -> Result<ContextAssembler, CellstateError>
Create a context assembler with segment-based budget.
Sourcepub fn assemble(
&self,
pkg: ContextPackage,
) -> Result<ContextWindow, CellstateError>
pub fn assemble( &self, pkg: ContextPackage, ) -> Result<ContextWindow, CellstateError>
Assemble context from a package with token budget management. Sections are added in priority order until budget is exhausted.
When segment budget is configured, sections are also checked against their respective segment budgets.
§Arguments
pkg- The context package to assemble
§Returns
An assembled ContextWindow with sections ordered by priority
Sourcepub fn reassemble(
&self,
current: &ContextWindow,
updated_pkg: ContextPackage,
) -> Result<(ContextWindow, ContextPageDiff), CellstateError>
pub fn reassemble( &self, current: &ContextWindow, updated_pkg: ContextPackage, ) -> Result<(ContextWindow, ContextPageDiff), CellstateError>
Re-assemble a context window mid-scope after scoring changes.
Takes the current window and an updated context package (with re-scored
notes/artifacts), reassembles from scratch using the same budget rules,
then diffs the old and new windows to produce a ContextPageDiff.
This is a pure function — no I/O. The diff provides the audit trail for what was evicted, promoted, or retained.
§Returns
Tuple of (new window, diff describing what changed).
Sourcepub fn token_budget(&self) -> i32
pub fn token_budget(&self) -> i32
Get the token budget from config.
Trait Implementations§
Source§impl Clone for ContextAssembler
impl Clone for ContextAssembler
Source§fn clone(&self) -> ContextAssembler
fn clone(&self) -> ContextAssembler
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more