pub fn plan_rollover(
messages: &[SharedMessage],
budget: SuccessorBudget,
before_tokens: u64,
transcript_path: impl Fn(u64) -> PathBuf,
) -> Option<RolloverPlan>Expand description
Plan a rollover of messages into budget (message tokens, estimator
units). transcript_path(window) names the file the evicted window is
saved to. None when nothing can be evicted (no assistant round before
the last one, or no valid cut); the caller treats that as no-shrink.
The successor is: the brief (message 0, always, even over budget); later
orchestrator instructions from the evicted range, newest first within
[PINNED_SHARE_PERCENT] of the budget; the host note; and the longest
contiguous suffix that starts at an assistant message no tool group
straddles and fits the rest of the budget. The last assistant message and
everything after it are always kept.