pub struct OscillationDetector { /* private fields */ }Expand description
Per-surface oscillation detector. Records recent patch_hash
values from Decision::Patch outcomes and reports whether a
fresh proposal would repeat one we’ve seen recently — that’s
the A→B→A pattern the loop must not commit to.
Thread-safety: backed by DashMap so the handler can hold it
behind Arc and call check_and_record from any async context
without taking a tokio Mutex first.
Implementations§
Source§impl OscillationDetector
impl OscillationDetector
pub fn new() -> Self
Sourcepub fn check_and_record(&self, surface_id: &str, patch_hash: u64) -> bool
pub fn check_and_record(&self, surface_id: &str, patch_hash: u64) -> bool
Test whether patch_hash would oscillate against the
surface’s recent history, and either record it (no
oscillation, proceed) or leave history untouched
(oscillation, caller suppresses the apply).
Returns true when the caller should APPLY the patch.
Returns false when the patch repeats one in the recent
window — caller logs and skips.
Trait Implementations§
Source§impl Default for OscillationDetector
impl Default for OscillationDetector
Source§fn default() -> OscillationDetector
fn default() -> OscillationDetector
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OscillationDetector
impl !RefUnwindSafe for OscillationDetector
impl Send for OscillationDetector
impl Sync for OscillationDetector
impl Unpin for OscillationDetector
impl UnsafeUnpin for OscillationDetector
impl UnwindSafe for OscillationDetector
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
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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>
Converts
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>
Converts
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 more