pub struct ProgressToken(pub u64);Expand description
A per-turn, monotonically advancing marker of forward progress.
§Why this exists (EVE-534)
A durable turn that crashes and gets reclaimed repeatedly can loop forever (re-running reason/act, burning tokens/billing) until it incidentally hits max-iterations. To defend against this poison-turn case we need a notion of progress that is:
- Derived from durably-recorded facts so it is stable under replay — the
highest
durable_workflow_events.sequence_numfor the turn’s workflow, or equivalently the(iteration, atoms_completed, settled_tool_calls)tuple. - Impossible to game by a non-advancing retry — re-running the same atom that crashes before recording any event leaves the token unchanged.
The token is a single u64 so the no-progress guard can compare cheaply and
persist it on the task across recovery attempts. A strictly larger value
means the turn advanced; an equal (or smaller) value means it did not.
Tuple Fields§
§0: u64Implementations§
Source§impl ProgressToken
impl ProgressToken
Sourcepub const ZERO: ProgressToken
pub const ZERO: ProgressToken
The token before any durable fact has been recorded.
Sourcepub fn from_event_sequence(highest_sequence: i64) -> Self
pub fn from_event_sequence(highest_sequence: i64) -> Self
Build a token from the highest durable event sequence observed for the
turn. Sequence numbers are monotonic per workflow, so this is monotonic
per turn. The +1 keeps ZERO reserved for “no events yet” while a
missing/-1 sequence maps to ZERO.
Sourcepub fn advanced_from(&self, prev: ProgressToken) -> bool
pub fn advanced_from(&self, prev: ProgressToken) -> bool
Returns true if self represents strictly more progress than prev.
Trait Implementations§
Source§impl Clone for ProgressToken
impl Clone for ProgressToken
Source§fn clone(&self) -> ProgressToken
fn clone(&self) -> ProgressToken
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ProgressToken
Source§impl Debug for ProgressToken
impl Debug for ProgressToken
Source§impl<'de> Deserialize<'de> for ProgressToken
impl<'de> Deserialize<'de> for ProgressToken
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ProgressToken
Source§impl Ord for ProgressToken
impl Ord for ProgressToken
Source§fn cmp(&self, other: &ProgressToken) -> Ordering
fn cmp(&self, other: &ProgressToken) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ProgressToken
impl PartialEq for ProgressToken
Source§impl PartialOrd for ProgressToken
impl PartialOrd for ProgressToken
Source§impl Serialize for ProgressToken
impl Serialize for ProgressToken
impl StructuralPartialEq for ProgressToken
Auto Trait Implementations§
impl Freeze for ProgressToken
impl RefUnwindSafe for ProgressToken
impl Send for ProgressToken
impl Sync for ProgressToken
impl Unpin for ProgressToken
impl UnsafeUnpin for ProgressToken
impl UnwindSafe for ProgressToken
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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