pub struct ContextAssembler { /* private fields */ }Expand description
Assembler for deterministic context construction per CP-021.
Implementations§
Source§impl ContextAssembler
impl ContextAssembler
pub fn new(budget: TokenBudget) -> Self
Sourcepub fn with_budget(total_tokens: usize) -> Self
pub fn with_budget(total_tokens: usize) -> Self
Create with a simple token budget.
Sourcepub fn assemble(
&self,
chunks: Vec<ScoredChunk>,
query: &str,
state_root: [u8; 32],
) -> AssembledContext
pub fn assemble( &self, chunks: Vec<ScoredChunk>, query: &str, state_root: [u8; 32], ) -> AssembledContext
Assemble chunks into a deterministic, byte-identical context.
Per CP-021 §11:
- Deduplicate by chunk ID and text hash (80% overlap threshold)
- Sort deterministically: score desc → doc path asc → seq asc →
byte_offsetasc - Group by document
- Greedy pack within budget
- Format with [DOC: path] markers
Sourcepub fn format(context: &AssembledContext) -> String
pub fn format(context: &AssembledContext) -> String
Format the assembled context as a string with [DOC: path] markers.
Per CP-021 §9.
Auto Trait Implementations§
impl Freeze for ContextAssembler
impl RefUnwindSafe for ContextAssembler
impl Send for ContextAssembler
impl Sync for ContextAssembler
impl Unpin for ContextAssembler
impl UnsafeUnpin for ContextAssembler
impl UnwindSafe for ContextAssembler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more