pub struct AdaptiveRingSidecar { /* private fields */ }Expand description
Background scanner thread that drives shape morphs on an
AdaptiveRing from a RingShapePolicy.
spawn starts the thread; shutdown stops it. The thread
scans every scan_interval, builds a PolicyObservation,
asks the policy, and calls AdaptiveRing::morph_to on
Some(new_shape) responses.
Implementations§
Source§impl AdaptiveRingSidecar
impl AdaptiveRingSidecar
Sourcepub fn spawn<P: RingShapePolicy>(
ring: Arc<AdaptiveRing>,
policy: P,
scan_interval: Duration,
) -> Self
pub fn spawn<P: RingShapePolicy>( ring: Arc<AdaptiveRing>, policy: P, scan_interval: Duration, ) -> Self
Spawn a sidecar thread that morphs ring according to
policy decisions sampled every scan_interval.
Sourcepub fn spawn_gated<P: RingShapePolicy>(
ring: Arc<AdaptiveRing>,
policy: P,
scan_interval: Duration,
gate_cfg: GateConfig,
) -> Self
pub fn spawn_gated<P: RingShapePolicy>( ring: Arc<AdaptiveRing>, policy: P, scan_interval: Duration, gate_cfg: GateConfig, ) -> Self
As spawn with a confidence gate between
the shape policy’s recommendation and the morph. Disabled
(the default config) reproduces spawn exactly.
Sourcepub fn spawn_with_qos<P: RingShapePolicy, O: OrderingPolicy>(
ring: Arc<AdaptiveRing>,
shape_policy: P,
ordering_policy: O,
qos: Arc<QosPolicy>,
scan_interval: Duration,
) -> Self
pub fn spawn_with_qos<P: RingShapePolicy, O: OrderingPolicy>( ring: Arc<AdaptiveRing>, shape_policy: P, ordering_policy: O, qos: Arc<QosPolicy>, scan_interval: Duration, ) -> Self
Spawn a sidecar that consults BOTH axes every scan tick: the
shape policy (peer counts + the QoS ordering declaration, via
QosRingShapePolicy or any custom RingShapePolicy) and
the ordering policy (declaration + observed inversion rate).
Per tick, on a stamped ring the sidecar additionally:
- computes inversions/sec from the shared counter’s delta,
- ticks the drainer-lease epoch so a dead merge drainer
becomes preemptible after
DRAINER_GRACE_EPOCHSscans, - applies the ordering policy’s decision via
set_ordering_mode(counted inordering_flips).
The shape axis is UNGATED by default: capacity-class morphs
are cheap to reverse (the warm-backing path makes them
microsecond-scale), so tracking load faithfully beats
deliberating. The ordering AUTO-arm is GATED by default: the
inversion-rate-driven Unordered -> MergeByStamp flip is
one-way (merged pops read zero inversions, so there is no
symmetric signal to walk it back), and a one-way decision
taken on a single noisy scan is unrecoverable. The gate
makes the auto-arm demand sustained inversions before it
commits. Explicit caller declarations (GlobalFifo arm,
declaration withdrawal) are NOT noise and fire immediately -
only the auto-detected arm is deliberated.
spawn_with_qos_gated overrides both axes with one explicit
config (disabled reproduces the fully-ungated behavior).
Sourcepub fn spawn_with_qos_gated<P: RingShapePolicy, O: OrderingPolicy>(
ring: Arc<AdaptiveRing>,
shape_policy: P,
ordering_policy: O,
qos: Arc<QosPolicy>,
scan_interval: Duration,
gate_cfg: GateConfig,
) -> Self
pub fn spawn_with_qos_gated<P: RingShapePolicy, O: OrderingPolicy>( ring: Arc<AdaptiveRing>, shape_policy: P, ordering_policy: O, qos: Arc<QosPolicy>, scan_interval: Duration, gate_cfg: GateConfig, ) -> Self
As spawn_with_qos with confidence
gates on BOTH axes set from one explicit config - a shape
gate and an ordering-auto-arm gate (each accumulates its own
conviction; a peer-count change shocks both). GateConfig::default()
(disabled) reproduces the fully-ungated sidecar; an enabled
config gates the shape morph AND the ordering auto-arm.
Explicit ordering declarations always fire immediately
regardless of config - the gate governs the auto-detected
arm only.
Sourcepub fn morphs_triggered(&self) -> u64
pub fn morphs_triggered(&self) -> u64
Number of successful morph_to calls the sidecar has issued since spawn.
Sourcepub fn ordering_flips(&self) -> u64
pub fn ordering_flips(&self) -> u64
Number of ordering-mode flips this sidecar has issued since
spawn (always 0 for spawn).