pub struct ModelContextScan { /* private fields */ }Expand description
Accumulates newest-to-oldest rollout items until they are sufficient to reconstruct the latest model context.
Storage implementations own how they fetch older items. Local JSONL readers and future reverse-paged cloud readers can both feed their items through this scan to share the cutoff rules and chronological replay assembly.
The scan stops once it has both:
saw_compaction: aCompactedItemwithreplacement_historyandwindow_number;saw_completed_turn_context: a completed user turn with a compatibleTurnContextItem.
If the scan reaches the beginning before finding a bounded cutoff, it has already collected the complete replay and so we can return that directly.
TurnContextItem does not identify whether it came from a user turn, so one only counts after
the same turn also proves a user-turn boundary: a paginated
ItemCompleted(UserMessage) marker, agent message, or inter-agent message. Paginated writers
persist that marker for real user turns; older rollouts without it conservatively scan to the
beginning. A raw role=user response item is not sufficient because contextual user fragments
use that role but do not count as turn boundaries during reconstruction. The compaction restores
model-visible items; the turn context restores previous settings (model, comp_hash, and
realtime_active) and the reference baseline.
These paginated shapes disable the bounded cutoff:
- compaction without
replacement_historyorwindow_number; - rollback markers;
When one appears, the scanner continues to the beginning and returns the complete replay.
Implementations§
Source§impl ModelContextScan
impl ModelContextScan
Sourcepub fn push(&mut self, item: RolloutItem) -> ModelContextScanProgress
pub fn push(&mut self, item: RolloutItem) -> ModelContextScanProgress
Adds the next newest-to-oldest rollout item and reports whether the reader can stop.
Sourcepub fn finish(self, session_meta: SessionMetaLine) -> Vec<RolloutItem>
pub fn finish(self, session_meta: SessionMetaLine) -> Vec<RolloutItem>
Returns the collected items in chronological order with canonical head metadata.
Call this after the reader reaches the beginning of its source or after Self::push
returns ModelContextScanProgress::Complete.
Trait Implementations§
Source§impl Debug for ModelContextScan
impl Debug for ModelContextScan
Source§impl Default for ModelContextScan
impl Default for ModelContextScan
Source§fn default() -> ModelContextScan
fn default() -> ModelContextScan
Auto Trait Implementations§
impl Freeze for ModelContextScan
impl RefUnwindSafe for ModelContextScan
impl Send for ModelContextScan
impl Sync for ModelContextScan
impl Unpin for ModelContextScan
impl UnsafeUnpin for ModelContextScan
impl UnwindSafe for ModelContextScan
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request