Skip to main content

roll_over

Function roll_over 

Source
pub fn roll_over(
    messages: &[SharedMessage],
    budget: SuccessorBudget,
    before_tokens: u64,
    overhead_tokens: u64,
    policy: &WorkerPolicy,
    sink: &WorkerTranscriptSink,
    hard_capacity: Option<u64>,
) -> Result<Option<(Vec<SharedMessage>, WorkerRolloverReport)>>
Expand description

Apply one worker rollover: plan it, refuse one that cannot shrink the context or would start where the next round triggers another rollover (the pressure band below hard capacity, the hard-capacity line at it), save the evicted messages, and return the successor with its report. hard_capacity is Some(line) for a rollover at hard capacity, where line is the footprint at which the next round is at hard capacity (context_window - required_next_round). Ok(None) = no-shrink (the caller defers like the foreground’s unproductive rollover). An error writing the transcript means no rollover: nothing is evicted that was not saved.