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: CellstateConfigConfiguration for assembly
segment_budget: Option<TokenBudget>Segment-based token budget (optional)
Implementations§
Source§impl ContextAssembler
impl ContextAssembler
Sourcepub fn new(config: CellstateConfig) -> CellstateResult<Self>
pub fn new(config: CellstateConfig) -> CellstateResult<Self>
Create a new context assembler with the given configuration.
Sourcepub fn with_segment_budget(
config: CellstateConfig,
budget: TokenBudget,
) -> CellstateResult<Self>
pub fn with_segment_budget( config: CellstateConfig, budget: TokenBudget, ) -> CellstateResult<Self>
Create a context assembler with segment-based budget.
Sourcefn section_to_segment(section_type: SectionType) -> ContextSegment
fn section_to_segment(section_type: SectionType) -> ContextSegment
Map SectionType to ContextSegment for budget tracking.
Sourcepub fn assemble(&self, pkg: ContextPackage) -> CellstateResult<ContextWindow>
pub fn assemble(&self, pkg: ContextPackage) -> CellstateResult<ContextWindow>
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,
) -> CellstateResult<(ContextWindow, ContextPageDiff)>
pub fn reassemble( &self, current: &ContextWindow, updated_pkg: ContextPackage, ) -> CellstateResult<(ContextWindow, ContextPageDiff)>
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).
Sourcefn diff_windows(old: &ContextWindow, new: &ContextWindow) -> ContextPageDiff
fn diff_windows(old: &ContextWindow, new: &ContextWindow) -> ContextPageDiff
Compare two context windows and produce a diff.
Sourcefn build_sections(&self, pkg: &ContextPackage) -> Vec<ContextSection>
fn build_sections(&self, pkg: &ContextPackage) -> Vec<ContextSection>
Build sections from a context package.
Sourcefn format_kernel_config(&self, kernel: &KernelConfig) -> String
fn format_kernel_config(&self, kernel: &KernelConfig) -> String
Format kernel config into a string.
Sourcefn format_notes(&self, notes: &[Note]) -> String
fn format_notes(&self, notes: &[Note]) -> String
Format notes into a string.
Sourcefn format_artifacts(&self, artifacts: &[Artifact]) -> String
fn format_artifacts(&self, artifacts: &[Artifact]) -> String
Format artifacts into a string.
Sourcefn format_working_set(&self, entries: &[AgentWorkingSetEntry]) -> String
fn format_working_set(&self, entries: &[AgentWorkingSetEntry]) -> String
Format working-set entries into a string.
Sourcefn format_graph_links(&self, links: &[GraphLink]) -> String
fn format_graph_links(&self, links: &[GraphLink]) -> String
Format graph links into a string.
Sourcefn format_turns(&self, turns: &[Turn]) -> String
fn format_turns(&self, turns: &[Turn]) -> String
Format conversation turns into a string.
Sourcefn format_hierarchy(&self, hierarchy: &[Trajectory]) -> String
fn format_hierarchy(&self, hierarchy: &[Trajectory]) -> String
Format trajectory hierarchy into a string.
Sourcefn format_scope_summaries(&self, summaries: &[ScopeSummary]) -> String
fn format_scope_summaries(&self, summaries: &[ScopeSummary]) -> String
Format scope summaries into a string.
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